need some help (forms involved)
Posted: Fri Jun 23, 2006 10:38 pm
Hi, I've just recently taken up php again. I have a problem. I have two pages that work together - one displays some variables and the other processes the input of a form that I have on the first page. You may have noticed that I have been following along with the php.net tutorial - but I've done my best to learn as much as I could while moving through it. When I push the submit button on the form, I get this error:
Here is my first page (index.php)
Here is the second page (action.php)
Could you guys help me sort out that nasty error I've been getting? I really am not sure what an unexpected T_Variable is... though I know it has somethign to do with a form value. Also, I would apprechiate it if you all could point out logical flaws, or inncorrect structure within my code. Thank you!
Code: Select all
Parse error: parse error, unexpected T_VARIABLE, expecting '(' in /home/mabufo/www/action.php on line 10Code: Select all
<html>
<head>
<title>Welcome to Line Break</title>
</head>
<body>
<?php echo '<p>Hello everyone!</p>'; ?>
<br />
<?php if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') == False) {
echo 'You are not using IE.';
}
?>
<?php if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== False) {
echo 'You are using IE.';
}
?>
<br />
<?php echo 'You are using: ';
echo $_SERVER['HTTP_USER_AGENT'];
?>
Here is a little thing for you to fill out...<br />
<form action="action.php" method="post">
<p>Name: <input type="text" name="Handle" /></p>
<p>Age: <input type="text" name="yearsOld" /></p>
<p>Browser: <input type="text" name="browser" /></p>
<p> <input type="submit"/></p>
</form>
</body>
</html>Code: Select all
<html>
<head>
<title>Form Results.</title>
</head>
<body>
<br />
You're name is: <?php echo $_POST['handle']; ?>
<?php if $_POST['handle'] == 'matt' {
echo 'Hey, my name is matt too! <br />'
}
?>
<br />
<br />
You are <?php echo $_POST['yearsOld']; ?> years of age.<br />
You said you are using: <?php echo $_POST['browser']; ?>
<?php if (strpos($_SERVER['HTTP_USER_AGENT'], $_POST['browser]) == True {
echo 'You are using your communicated browser. <br />';
} else {
echo 'You lied! You are using: ';
echo $_SERVER['HTTP_USER_AGENT'];
}<br />
</body>
</html>