Problem with PHP and HTML Forms
Posted: 30. December 2006 19:49
I am trying to get HTML forms working with xampp lite and having trouble getting them to work. I have included the HTML and PHP code below. As far as I can tell, I am coding this properly. The HTML code will display the form and when I select the Submit button on the form, it calls the PHP file but the PHP code is never executed. Any ideas?
HTML code - TestPHPForm.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<!--
HTML 3.2
Document type as defined on http://www.w3.org/TR/REC-html32
-->
<head>
<title>Title here!</title>
</head>
<body>
<h4>Tizag Art Supply Order Form</h4>
<form action="TestPHPForm.php" method="post">
<select name="item">
<option>Paint</option>
<option>Brushes</option>
<option>Erasers</option>
</select>
Quantity: <input name="quantity" type="text" />
<input type="submit" />
</form>
</body>
</html>
PHP code - TestPHPForm.php
<!doctype html public "-//W3C//DTD HTML 4.0 //EN">
<html>
<head>
<title>TestPHPForm.php</title>
</head>
<body>
<?php
$quantity = $_POST['quantity'];
$item = $_POST['item'];
echo "You ordered ". $quantity . " " . $item . ".<br />";
echo "Thank you for ordering from Tizag Art Supplies!";
?>
</body>
</html>
HTML code - TestPHPForm.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<!--
HTML 3.2
Document type as defined on http://www.w3.org/TR/REC-html32
-->
<head>
<title>Title here!</title>
</head>
<body>
<h4>Tizag Art Supply Order Form</h4>
<form action="TestPHPForm.php" method="post">
<select name="item">
<option>Paint</option>
<option>Brushes</option>
<option>Erasers</option>
</select>
Quantity: <input name="quantity" type="text" />
<input type="submit" />
</form>
</body>
</html>
PHP code - TestPHPForm.php
<!doctype html public "-//W3C//DTD HTML 4.0 //EN">
<html>
<head>
<title>TestPHPForm.php</title>
</head>
<body>
<?php
$quantity = $_POST['quantity'];
$item = $_POST['item'];
echo "You ordered ". $quantity . " " . $item . ".<br />";
echo "Thank you for ordering from Tizag Art Supplies!";
?>
</body>
</html>