2

I have a css div html form for a contact page and would like the form to be emailed when sent. Being a newbie at PHP ive tried different examples and can get the mail to be sent but cant get the form data with in the email.

html code

           <div class="maincontent">
  <div class="content">
  <article class="topcontent">
  <content>
  <div id="form-main">
  <div id="form-div">
  <form method="post" enctype="text/plain" action="mail.php" class="form" id="form1">
  <p class="name">
  <input name="name" type="text" class="validate[required,custom[onlyLetter],length[0,100]] feedback-input" placeholder="Name" id="name" />
  </p>
  <p class="email">
  <input name="email" type="text" class="validate[required,custom[email]] feedback-input" id="email" placeholder="Email" />
  </p>
  <p class="text">
  <textarea name="text" class="validate[required,length[6,300]] feedback-input" id="comment" placeholder="Comment"></textarea>
  </p>
  <div class="submit">
  <input type="submit" value="SEND" id="button-blue"/>
  <div class="ease"></div>
  </div>
  </form>
  </div>
  </content>    
  </article>
  </div>
  </div>

PHP Mail Script

    <?php
require("class.phpmailer.php");
$formcontent="From: $name \n Message: $text \n Email: $email";
$mail = new PHPMailer();
$mail->IsSMTP();                                      // set mailer to use SMTP
$mail->Host = "localhost;";  // specify main and backup server
$mail->SMTPAuth = false;     // turn on SMTP authentication
$mail->Username = "jswan";  // SMTP username
$mail->Password = "secret"; // SMTP password
$name = $_POST['name']; // contain name of person
$email = $_POST['email']; // Email address of sender 
$message = $_POST['text']; // Your message
$mail->AddAddress('warren@.com', 'recipient email');
$mail->From = "noreply@.com";
$mail->FromName = "Contact Us Information";
$mail->Subject = "Website Contact Us Information";
$mail->Body = "Name:{$name}\n\nEmail:{email}\n\nComments:{$body}";
$mail->WordWrap = 50;                                 // set word wrap to 50 characters
$mail->IsHTML(true);                                  // set email format to HTML
if(!$mail->Send())
{
echo "Message could not be sent. <p>";
echo "Mailer Error: " . $mail->ErrorInfo;
exit;
}
echo "Message has been sent";
?>

Like I said, mail is sent but without the form information.

Thanks

WazSA11
  • 23
  • 3
  • Have you tried `print_r()`-ing the $_POST variable see if it contains anything? – Rimble May 21 '14 at 08:00
  • The removing of enctype="text/plain" solved the problem. How would I now get the form data a list format eg: – WazSA11 May 21 '14 at 08:43

1 Answers1

0

Take out enctype="text/plain" from the form tag.

Using this you can not get the posted data.

Abhik Chakraborty
  • 44,654
  • 6
  • 52
  • 63