$num_to_guess = 42;
$message = "";
if (! isset ( $_POST ['guess'] )) {
$message = "Welcome!";
} else if ($_POST ['guess'] > $num_to_guess) {
$message = $_POST ['guess'] . " is too big!";
} else if ($_POST ['guess'] < $num_to_guess) {
$message = $_POST ['guess'] . " is too small!";
} else {
$message = "Well done!";
}
$guess = ( int ) $_POST ['guess'];
$num_tries = ( int ) $_POST ['num_tries'];
$num_tries ++;
?>
A PHP Number Guessing Script
Guess number:
print $_SERVER ['PHP_SELF']?>">
value=" print $num_tries?>" /> Type your guess here: print $guess?>" />