I'm writing my first php program and I'm having a problem. I'm receiving a "undefined index" message after using the "post' action in my form page, which calls the php page.

contactus.html:
<form action="reply.php" method="POST" name="ContactUs" target="_blank" enctype="text/plain">
<p> What is your name?<br>
<input name="name" type="text" size="35" maxlength="100">
</p>
<p>
What is your email address?<br>
<input name="email" type="text" size="35" maxlength="100">
</p>
<p>What is your street address?<br>
<input name="StreetAddress" type="text" size="35" maxlength="150">
</p>
<p>What city do you live in?<br>
<input name="city" type="text" size="35" maxlength="100">
</p>
<p>What is your zip code?<br>
<input name="zipcode" type="text">
</p>
<p><strong>Tell us your thoughts. </strong></p>
<p>* Please use the area below to communicate your suggestions, ideas, comments or questions.</p>
<p>
<textarea name="textarea" cols="75" rows="10"></textarea>
</p>
<p>
<input name="SubmitButton" type="submit" value="Submit">
<input name="clear" type="reset" value="Clear">
</p>
</form>

the php page is:

Reply.php
<?php
/
build email msg, and build output screen
/
$to = "milthall@attglobal.net";
$subject = "contact Us - comments";
$name = $POST['name'];
$email = $
POST['email'];

$address = $POST['StreetAddress'];

$city = $
POST['city'];
$zipcode = $POST['zipcode'];

$text = $
POST['textarea'];
$message = "name = " . $name . "email = " . $email . "address = " . $address . "city = " . $city . "zipcode = " . $zipcode . "comments = " . $text;
$headers = "From: CAAM website comments\r\n";
mail($to,$subject,$message,$headers);
echo "Hello\n\n\n";
echo "your name is = " . $name . "\n\n";
echo "your email address is = " . $email . "\n\n";
echo "your address is = " . $address . "\n\n";
echo "your city is = " . $city . "\n\n";
echo "your zip code is = " . $zipcode . "\n\n";
echo "your comments are = " . $text . "\n\n";
?>

and the error messages are:
Notice: Undefined index: name in C:\Inetpub\wwwroot\caam\reply.php on line 22

Notice: Undefined index: email in C:\Inetpub\wwwroot\caam\reply.php on line 23

Notice: Undefined index: StreetAddress in C:\Inetpub\wwwroot\caam\reply.php on line 24

Notice: Undefined index: city in C:\Inetpub\wwwroot\caam\reply.php on line 25

Notice: Undefined index: zipcode in C:\Inetpub\wwwroot\caam\reply.php on line 26

Notice: Undefined index: textarea in C:\Inetpub\wwwroot\caam\reply.php on line 27
Hello your name is =
your email address is = your address is = your city is = your zip code is = your comments are =

Does anyone have an idea of what is happening? thanks.

    Sounds like the form isn't posting to the PHP page....

    What doctype are you using (if any)?

    ~Brett

      This is the line causing the problem.

      <form action="reply.php" method="POST" name="ContactUs" target="_blank" enctype="text/plain">

      I have run the program as below, but you need to fix the format of the php possibly also the email message, you will see because my localhost sent you and myself a message while testing the file. Just changed the enctype as below.

      <form action="reply.php" method="POST" name="ContactUs" target="_blank" enctype="multipart/form-data">
      <p>* What is your name?<br>
      <input name="name" type="text" size="35" maxlength="100">
      </p>
      <p>* What is your email address?<br>
      <input name="email" type="text" size="35" maxlength="100">
      </p>
      <p>What is your street address?<br>
      <input name="StreetAddress" type="text" size="35" maxlength="150">
      </p>
      <p>What city do you live in?<br>
      <input name="city" type="text" size="35" maxlength="100">
      </p>
      <p>What is your zip code?<br>
      <input name="zipcode" type="text">
      </p>
      <p><strong>Tell us your thoughts. </strong></p>
      <p>* Please use the area below to communicate your suggestions, ideas, comments or questions.</p>
      <p> 
      <textarea name="textarea" cols="75" rows="10"></textarea>
      </p>
      <p> 
      <input name="SubmitButton" type="submit" value="Submit">
      <input name="clear" type="reset" value="Clear">
      </p>
      </form>

      Now all you need to do is format the little message in both the email and the echo with the double newlines should also have <br />'s added because the \n\n will not show up in a browser but will in the source code.

        Or remove the enctype all together.....

          4 days later

          Thanks Houdini and Bret,

          I changed the encytype to multipart/form as you suggested and I replaced the "\nl" with the <br> and everything works fine now.

          Milton

            Write a Reply...