problem with IF()
Posted: Sat Jun 11, 2011 12:32 am
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.
Code: Select all
<?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>"
;
?>Code: Select all
<?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.";
}
?>