I'm going through SAMS Teach Yourself PHP, MYSQL, and Apache all in one and I can't seem to get this example to work, which is used again in the next lesson. I usually type them in by hand as this one, but I've also tried cutting and pasting and removing the line numbers directly from the online tutorial, and still can't get anything but a blank page.
Thanks in advance for any help!
<?php
$num_to_guess = 42;
if(!isset($_POST[guess]])) {
$message = "WElcome to the guessing machine!";
}
else if($_POST[guess] > $num_to_guess) {
$message = "$_POST[guess] is too big! Try a smaller number.";
}
else if($_POST[guess] < $num_to_guess) {
$message = "$_POST[guess] is too small! Try a larger number.";
}
else {
$message = "Well Done!";
}
?>
<html>
<head>
<title> A PHP number guessing script</title>
</head>
<body>
<h1><?php echo $message; ?></h1>
<form action="<?php echo $_SERVER[PHP_SELF]; ?>" method="POST">
<p><strong>Type your guess here:</strong><input type="text" name="guess"></p>
<p><input type="submit" value="submit your guess"></p>
</form>
</body>
</html>