PHP send mail script isn't sending the form fields

Discussion in 'PHP' started by mickapoo, Oct 17, 2008.

  1. #1
    I have an HTML form that has both an email address and a name field.

    When I submit the form, I do receive the email, but the only thing that is in the email is the users email address. The name that they enter is there. And the field name is lower case, just as it is below.


    Here is my PHP script:
    
    <?php
      $email = $_POST['email'] ;
      $message = $_POST['name'] ;
    
    
      mail( "info@mydomain.com", "Opt In",
        $message, "From: $email" );
      header( "Location: http://www.mydomain.com/thanks.html" );
    ?>
    
    Code (markup):
    Can you tell me why I may not be receiving the name in the email?

    And also, if I want to add more fields to the form, how would I do that? Would I change it to
    $message = $_POST['name', 'other field name', 'other field name'] ?


    Thank you!
     
    mickapoo, Oct 17, 2008 IP
  2. serialCoder

    serialCoder Guest

    Best Answers:
    0
    #2
    your code looks good, it would help a lot if you could also paste the form.

    as for your 2nd question you can concatenate the fields.

    Ex:

    $message = $_POST['somefield'] . $_POST['anotherfield'];

    OR

    $message = $_POST['somefield'];
    $message .= $_POST['anotherfield'];
     
    serialCoder, Oct 17, 2008 IP