Posted by Dan Oakes on 07/10/07 05:17
I'm new to PHP and I can't get this simple script to run - it gives an
error on line 31. What am I doing wrong?
Thanks,
Dan
<?php
$message = "";
if ( ! isset( $_POST['guess'] ) ) {
$message = "This is an if/then, loop program.";
} else if ( $_POST['guess'] > 101 ) {
$message = $_POST['guess']." is too big!";
} else {
for ($i = 1; $i <= $_POST['guess']; $i++ ) {
$message = "Number $i\n";
}
?>
<html>
<head>
<title>If/Then, Loop Program</title>
</head>
<body><basefont face="verdana">
<b>
<?php print $message ?>
</b>
<form method="post" action="<?php print $_SERVER['PHP_SELF']?>">
<p>
Type a number: <input type="text" name="guess" />
<input type="submit" value="submit" />
</p>
</form>
</body>
</html>
Navigation:
[Reply to this message]
|