Submitting Email Form

Discussion in 'PHP' started by suresh_gop, Aug 4, 2010.

  1. #1
    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"); 
    ?>
    
    PHP:
    How to get it?

    Thanks,
    Suresh Gopalakrishnan
     
    suresh_gop, Aug 4, 2010 IP
  2. arpit13

    arpit13 Well-Known Member

    Messages:
    294
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    128
    Digital Goods:
    1
    #2
    a . is missing:
    
    <?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");
    ?>
    
    PHP:
     
    arpit13, Aug 4, 2010 IP