$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!";
}
?>
A PHP Number Guessing Script