Page 1 of 1

Submitting email form

Posted: Wed Aug 04, 2010 9:13 am
by suresh_gop
Hello,

In my contact form, I have four fields Name, Country, Email and Comments. When i submit this form i am only receiving two fields data name and email only. I want to get country and comments data also. I have attached php code here.

Php code:

<?php
$ToEmail = 'sampleind@gmail.com';
$EmailSubject = 'Site contact form ';
$mailheader = "From: ".$_POST["email"]."\r\n";
$mailheader .= "Reply-To: ".$_POST["email"]."\r\n";
$mailheader .= "Content-type: text/html; charset=iso-8859-1\r\n";
$MESSAGE_BODY = "Name: ".$_POST["name"]."<br>";
$MESSAGE_BODY = "Country: ".$_POST["country"]."<br>";
$MESSAGE_BODY .= "Email: ".$_POST["email"]."<br>";
$MESSAGE_BODY .= "Comment: ".nl2br($_POST["comment"])."<br>";

mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader) or die ("Failure");
?>

How to get it?

Thanks,
Suresh Gopalakrishnan

Re: Submitting email form

Posted: Wed Aug 04, 2010 10:17 am
by klevis miho
Add a dot here:
$MESSAGE_BODY .= "Country: ".$_POST["country"]."<br>";

Re: Submitting email form

Posted: Wed Aug 04, 2010 10:25 am
by Denis1
Hello suresh_gop try the following. The message is in html so you can design it as you please
Enjoy :D :o

Code: Select all

<?php
$_POST["name"] = $name;
$_POST["country"] = $country;
$_POST["email"] =  $email;
nl2br($_POST["comment"])=  $comment;

$to = "sampleind@gmail.com";
$from = "".$_POST["email"]."";
$subject = "Site contact form ";

$message = "<html>
   <body background=\"#4B4B4B\">
   <h1>Site contact form</h1>
   Hello, <br>
    <center>
Name: $name <br>
Country: $country <br>
Email: $email <br>
Comment: $comment <br>
    </center>
  </body>
</html>";
   
    $headers  = "From: Site contact form <sampleind@gmail.com>\r\n";
    $headers .= "Content-type: text/html\r\n";

	mail($to, $subject, $message, $headers) or die ("Failure");
?>