<?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>" ;?>
<?php session_start(); ?> <?php$input = $_POST["inputcode"];$getcode = $_SESSION["getcode"]; echo 'Your input was: '.$input.'<br/>';echo 'The code was '.$getcode;?><hr/><?phpif ($input == $getcode){ echo "Code matched.";} else { echo "Code didn't match."; }?>