Hi there,
I'm a total newbie and would greatly appreciate help with this. Am working through SAMS PHP, MySQL and Apache book and cannot get this code to work. It's right from the book, I've gone over it a 100 times and I must be missing something that's right in front of me. It's a simple script.
Here's the code:
<?php
$numtoguess = 42;
if (!isset($POST["guess"])) {
$message = "Welcome to the guessing machine.";
} else if ($POST["guess"] > $numtoguess) {
$message = $POST["guess"]." is too large. Too bad try a smaller number.";
} else if ($POST["guess"] < $numtoguess) {
$message = $POST["guess"]."is too small. Too bad try a larger number.";
} else
$message = $POST["guess"]."is the number. Congratulations!";
}
/ tried else if and elseif they seem to use those interchangably - is that right? /
?>
<html>
<head>
<title>Testing...Testing...</title>
</head>
<body>
<h1><?php echo $message; ?></h1>
<form method="post" action="<?php echo $_SERVER["PHP_SELF"]; ?>">
<p><b>Type your guess here:</b>
<input type="text" name="guess" />
</p>
<p>
<input type="submit" value="Submit your guess" />
</p>
</form>
</body>
</html>
I'm suspicious of this $_POST{"guess"] code. But any help will be welcomed.
Thanks a lot for your time,
redtrout