Below is my code & here is my problem. I cannot figure out how the variables in the html are transfered/transmitted/become available for use, in the PHP script. That's posted below as well. I don't think this is a code problem... It's got to be a setup problem. I have tryed to get it to work on my server and using my local host and I get the same results in both cases. All I get is this err
Now Starting...
Notice: Undefined index: email in D:\wamp\www\Asimple.php on line 6
Email var is:
############ html file ################
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<META http-equiv="Content-Type" content="text/html">
<title>Simple.htm</title>
<style type="text/css"> BODY {background: lightyellow}
</style>
</head>
<body>
<FORM action="http://localhost/Asimple.php" method="post">
<p>
<LABEL for="firstname">First name: </LABEL>
<INPUT type="text" firstname="firstname" size="20" maxlength="40" />
<LABEL for="lastname">Last name: </LABEL>
<INPUT type="text" lastname="lastname" size="20" maxlength="40" /><BR>
<LABEL for="email">email address: </LABEL>
<INPUT type="text" email="email" size="30" maxlength="60" /><BR><BR>
<INPUT type="submit" value="Send"> <INPUT type="reset">
</p>
</FORM>
</body>
</html>
############ PHP file ##############
<?php # Script 1.0 - Asimple.php
ini_set('display_errors', 1);
echo "Now Starting... \n";
$email = $_POST['email'];
echo "Email var is: $email \n";
?>
Al's HTML PHP Form processing
Moderator: General Moderators
- flying_circus
- Forum Regular
- Posts: 732
- Joined: Wed Mar 05, 2008 10:23 pm
- Location: Sunriver, OR
Re: Al's HTML PHP Form processing
The problem is in your HTML form. firstname="firstname", lastname="lastname", etc. You need to name the form elements like such:
anemethy wrote:Code: Select all
<FORM action="http://localhost/Asimple.php" method="post"> <p> <LABEL for="firstname">First name: </LABEL> <INPUT type="text" name="firstname" size="20" maxlength="40" /> <LABEL for="lastname">Last name: </LABEL> <INPUT type="text" name="lastname" size="20" maxlength="40" /><BR> <LABEL for="email">email address: </LABEL> <INPUT type="text" name="email" size="30" maxlength="60" /><BR><BR> <INPUT type="submit" value="Send"> <INPUT type="reset"> </p> </FORM>
Re: Al's HTML PHP Form processing
My Children will thank you to the tenth generation !