Results 1 to 5 of 5

Thread: Submitting Email form

  1. #1
    Join Date
    May 2010
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Submitting Email form

    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

  2. #2
    Join Date
    Jul 2010
    Location
    Minnesota
    Posts
    256
    Thanks
    1
    Thanked 21 Times in 21 Posts

    Default

    The first issue is that you are not appending the Country to the $message_body, so this
    PHP Code:
    $MESSAGE_BODY "Country: ".$_POST["country"]."<br>"
    should be this
    PHP Code:
    $MESSAGE_BODY .= "Country: ".$_POST["country"]."<br>"
    But at the same time I'm not sure why you receive the name and not the country since you have reasigned the $message_body tag after the name. Have you tried taking off the nl2br part and see if it sends then?

  3. #3
    Join Date
    May 2010
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hi,

    Thanks for your respond. I tried your code and i am receiving three fields. How to get comments?

  4. #4
    Join Date
    Jul 2010
    Location
    Minnesota
    Posts
    256
    Thanks
    1
    Thanked 21 Times in 21 Posts

    Default

    did you take off the nl2br and try it? if so and still no change then try to echo out the comments and see if it contains anything before you send it. make sure you are referencing it correctly from your form.

  5. #5
    Join Date
    May 2010
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Now it works fine. very thanks...

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •