Mail Function/Passing Variables Help

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mbonbon
Forum Newbie
Posts: 1
Joined: Sat Oct 02, 2010 10:10 pm

Mail Function/Passing Variables Help

Post by mbonbon »

I'll first put that I'm new to php, so please bear with me.
I'm trying to make a mail form. I had gotten the mail to send but they kept coming in blank, or rather the input values were missing. So I added a check (you can see at the beginning of my code), to see what the issues were and it keeps coming back with "Notice: Undefined index: email1 in /home/content/d/h/l/dhlevinson/html/sendmail.php on line 5" (one for each of the variables I have), so I'm guessing that the variables aren't getting passed through, or they aren't being recognized, if this is the case I don't understand how, because my they are the same in my html code and my php code. Does anyone know why this would be happening?

I'm using Godaddy as a host and a Linux server, I figured I'd add that.

This is the HTML code:

Code: Select all

<h1>Contact</h1>
<form action="sendmail.php" method="post" enctype="text/plain"> Your Name:<br /> <input type="text" name="name1" /><br /><br /> Your E-mail Address:<br /> <input type="text" name="email1" /><br /><br /> Your Phone Number:<br /> <input type="text" name="phone1" /><br /><br /> Message:<br /><textarea class="message1"> </textarea><br /> <br /><br /> <input type="submit" value="Send" /> <input type="reset" value="Reset" /> </form> 
This is the PHP code:

Code: Select all

<?php
ini_set('display_errors', 1); // set to 0 for production version 
error_reporting(E_ALL);

$email = $_POST["email1"] ;
$name = $_POST["name1"] ;
$phone = $_POST["phone1"] ;
$message = $_POST["message1"] ;
$totalmessage = "
                Name: $name\n 
                Phone: $phone\n
		Message: $message \n";

if (!isset($_POST["email"])) {
    header( "Location: http://dhlevinson.com/contact.html" );
  }
  elseif (empty($email) || empty($message)) {
    header( "Location: http://dhlevinson.com/error.html" );
  }
  else {
  mail( "myemail@gmail.com", "Contact Drew Message", $message, "From: $email"  );

  header( "Location: http://www.dhlevinson.com/thankyou.html" );
}
 ?>
Thank you in advance to anyone who can help!
Post Reply