This week I started to learn about forms and how to use different methods of building them out.
This example is from my book and even though the actions and results are what the book says they should, I get an error message that I just can’t figure it out how to fix it.
I am using PHP 5.3.0 / apache 2.2.11 / mysql 5.1.36 on my test server
Code: Select all
<html>
<head>
<title>Feet to Meters Comversion Tool</title>
</head>
<body>
<?php
//check to see if the form has been submitted
$feet = $_GET["feet"];
if ($_GET[feet] != NULL) {
echo "<strong>$feet </strong> feet converts to <strong>";
echo $feet * 0.3048;
echo "</strong> meters.<br />";
}
?>
<form action="<?php echo($_SERVER['PHP_SELF']); ?>" method="GET">
<label>Feet:
<input type="text" name="feet" value="<?php echo $feet; ?>" />
</label>
<input type="submit" value="Convert!" />
</form>
</body>
</html>
Code: Select all
Notice: Undefined index: feet in C:\localhost\10-8.php on line 8
Notice: Use of undefined constant feet - assumed 'feet' in C:\localhost\10-8.php on line 9
Notice: Undefined index: feet in C:\localhost\10-8.php on line 9
[[b]the form goes here and it displays correctly[/b]]
When I enter a value to convert it into meters [34 feet into meters] it gives me the correct number but I also get this error message:
Code: Select all
Notice: Use of undefined constant feet - assumed 'feet' in C:\localhost\10-8.php on line 9
34 feet converts to 10.3632 meters.
Thanks for your help,