Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 06-11-2011, 01:09 AM Problems with IF()
Novice Talker

Posts: 12
Trades: 0
Im trying to make a very simple copy the code and if they match you can go on, but it doesnt seem to be working right at all. I can type in the same numbers as the code but the are not equel I dont get it . well here is my code. thank for your time.

This is the first page.
PHP Code:
<?php session_start(); ?>
<?php
$getcode 
=  rand() . "\n";
$_SESSION['getcode'] = $getcode;
$gettingcode $_SESSION['getcode'];

  echo 
"
  
  <form method='post' action='codetestpage.php'>
  Enter this code: "
.$getcode." <input name='inputcode' type='text' border='1' />
  <input value='Send' type='submit' />
  
  </form>"
  
;
?>

and it goes to to this.
PHP Code:
<?php session_start(); ?>
 
<?php
$input 
$_POST["inputcode"];
$getcode $_SESSION["getcode"];
 
echo 
'Your input was: '.$input.'<br/>';
echo 
'The code was '.$getcode;

?>

<hr/>

<?php
if ($input == $getcode)

echo 
"Code matched.";
}
 else 
 
 { 
  echo 
"Code didn't match.";
  
  }
?>
xwhitchx is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 06-11-2011, 11:56 AM Re: Problems with IF()
mgraphic's Avatar
Truth Seeker

Latest Blog Post:
JAMISONTUNES
Posts: 2,918
Name: Keith Marshall
Location: Connecticut
Trades: 0
Why do you put a new line after the getcode stored in the session? It's not matching probably because of the new line.
__________________

<mgraphic /> - I don't have a solution but I admire the problem.
mgraphic is offline
Reply With Quote
View Public Profile
 
Old 06-11-2011, 02:03 PM Re: Problems with IF()
Novice Talker

Posts: 12
Trades: 0
I took it out and its still not matching...
xwhitchx is offline
Reply With Quote
View Public Profile
 
Old 06-23-2011, 08:25 AM Re: Problems with IF()
Junior Talker

Posts: 1
Trades: 0
You need to cast the input as an integer

Line 4 should be .... $input = (int)$_POST["inputcode"];
zoidberg is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Problems with IF()
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.54950 seconds with 12 queries