- Code: Select all
<html>
<head></head>
<body>
<?php
/* if the "submit" variable does not exist, the form has not been submitted - display initial page */
if (!isset($_POST['submit'])) {
?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
Enter your age: <input name="age" size="2">
<input type="submit" name="submit" value="Go">
</form>
<?php
}
else {
/* if the "submit" variable exists, the form has been submitted - look for and process form data */
// display result
$age = $_POST['age'];
if ($age >= 21) {
echo 'Come on in, we have alcohol and music awaiting you!';
}
else {
echo 'You're too young for this club, come back when you're a little older';
}
}
?>
</body>
</html>
This is the code I copied and pasted from http://devzone.zend.com/node/view/id/628 and when I attempted to run it on Apache Server 2.2 (Using Php 5.0), I got this error
Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\allinone.php on line 25
I seen this error before when I forgot to add ; in, but from the limited knowledge I have from php, I don't see what's wrong with this. Any help?


