Re: quick php and forms question

  • From: "E.J. Zufelt" <everett@xxxxxxxxx>
  • To: <programmingblind@xxxxxxxxxxxxx>
  • Date: Tue, 2 Dec 2008 14:38:32 -0400

Good afternoon Alex,
Please find an example below. I had this code saved in a file named select.php.

Summary:

This code is for a simple html page with a select box and a submit button.

2. When the user submits the form the form is posted back to the same page.

3. You'll notice that there is a php code segment between the first level heading and the form. This code first checks to see if the form field that we are using has a value and then echos the result to the browser.

4. If you are still getting a parse error then you may have some configuration problem with your php or server.

select.php :

<html>
<head>
<title>Select PHP Example</title>

</head>
<body>
<h1>Select PHP Example</h1>

<?php

if (isset($_POST['lstSelect']))
{
echo "<div>";
echo "The value is: " . $_POST['lstSelect'];
echo "</div>";
}
?>

<form name="frmExample" action="select.php" method="post">
<select name="lstSelect">
<option value="1">Apple</option>
<option value="2">Pear</option>
<option value="3">Orange</option>
</select>
<input type="submit" value="Show Select Value" />
</form>
</body>
</html>
__________
View the list's information and change your settings at //www.freelists.org/list/programmingblind

Other related posts: