douxuanma4357
douxuanma4357
2013-06-09 13:02

我的PHP邮件表单显示为空,没有id信息

my php mail form comes up empty in my mailbox, for some reason it doesn't gather the textfield information typed in in the HTML.

This is how it shows up in my mailbox:

Email: 
First Name: 
Last Name: 
Phone: 
Vehicle:
Engine: 
Tickbox Engine: 
Tickbox Aerodynamics: 
Tickbox Wheels: 
Tickbox Suspension: 
Tickbox Exhaust: 
Tickbox Brakes: 
Tickbox Interior: 
Message:

This is my php code:

    $firtnameField = $_POST['firstname'];
    $lastnameField = $_POST['lastname'];
    $phonenameField = $_POST['phone'];
    $emailField = $_POST['email'];  
    $vehicleField = $_POST['vehicle'];  
    $engineField = $_POST['engine'];
    $tickboxengineField = $_POST['infoengine']; 
    $tickboxaerodynamicsField = $_POST['infoaero']; 
    $tickboxwheelsField = $_POST['infowheels']; 
    $tickboxsuspensionField = $_POST['infosuspension']; 
    $tickboexhaustField = $_POST['infoexhaust'];    
    $tickboxbrakesField = $_POST['infobrakes']; 
    $tickboxinteriorField = $_POST['infointerior']; 
    $tickboxmessageField = $_POST['message'];   
    $tickboxsendField = $_POST['infosend']; 

    $body = <<<EOD
<br><hr><br>
Email: $email <br>
First Name: $firstname <br>
Last Name: $lastname <br>
Phone: $phone <br>
Vehicle: $vehicle <br>
Engine: $engine <br>
Tickbox Engine: $infoengine <br>
Tickbox Aerodynamics: $infoaero <br>
Tickbox Wheels: $infowheels <br>
Tickbox Suspension: $infosuspension <br>
Tickbox Exhaust: $infoexhaust <br>
Tickbox Brakes: $infobrakes <br>
Tickbox Interior: $infointerior <br>
Message: $message <br>
EOD;

    $headers = "From: $email
";
    $headers .= "Content-type: text/html
";
    $succes = mail($webMaster, $emailSubject, $body, $headers);

And this is my HTML:

    <form id="form1" name="form1" method="post" action="requestform.php">
      <table width="540" border="0" align="center" cellpadding="0" cellspacing="0">
        <tr valign="bottom">
          <td width="48%" height="30" class="subheadline">First Name</td>
          <td width="4%" height="30">&nbsp;</td>
          <td width="48%" height="30" class="subheadline">Last Name</td>
        </tr>
        <tr>
          <td width="48%"><input name="firstname" type="text" id="firstname" size="45" /></td>
          <td width="4%">&nbsp;</td>
          <td width="48%"><input name="lastname" type="text" id="lastname" size="45" /></td>
        </tr>
        <tr valign="bottom">
          <td width="48%" height="30" class="subheadline">Phone</td>
          <td width="4%" height="30">&nbsp;</td>
          <td width="48%" height="30" class="subheadline">Email</td>
        </tr>
        <tr>
          <td width="48%"><input name="phone" type="text" id="phone" size="45" /></td>
          <td width="4%">&nbsp;</td>
          <td width="48%"><input name="email" type="text" id="email" size="45" /></td>
        </tr>
        <tr valign="bottom">
          <td width="48%" height="30" class="subheadline">Vehicle &amp; Model</td>
          <td width="4%" height="30">&nbsp;</td>
          <td width="48%" height="30" class="subheadline">Engine</td>
        </tr>
        <tr>
          <td width="48%"><input name="vehicle" type="text" id="vehicle" size="45" /></td>
          <td width="4%">&nbsp;</td>
          <td width="48%"><input name="engine" type="text" id="engine" size="45" /></td>
        </tr>
        <tr valign="bottom">
          <td width="48%" height="30" class="subheadline">Please select</td>
          <td width="4%" height="30">&nbsp;</td>
          <td width="48%" height="30">&nbsp;</td>
        </tr>
        <tr>
          <td colspan="3"><table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td height="25"><input type="checkbox" name="infoengine" id="infoengine" />
Engine Technology</td>
              <td height="25"><input type="checkbox" name="infoaero" id="infoaero" />
                Aerodynamics</td>
              <td height="25"><input type="checkbox" name="infowheels" id="infowheels" />
Sport Wheels</td>
              <td height="25"><input type="checkbox" name="infosuspension" id="infosuspension" />
                Suspension</td>
              </tr>
            <tr>
              <td height="25"><input type="checkbox" name="infoexhaust" id="infoexhaust" />
Exhaust Technology</td>
              <td height="25"><input type="checkbox" name="infobrakes" id="infobrakes" />Brake Technology</td>
              <td height="25"><input type="checkbox" name="infointerior" id="infointerior" />
                Interior</td>
              <td height="25">&nbsp;</td>
              </tr>
          </table></td>
          </tr>
        <tr valign="bottom">
          <td width="48%" height="30" class="subheadline">Message</td>
          <td width="4%" height="30">&nbsp;</td>
          <td width="48%" height="30">&nbsp;</td>
        </tr>
        <tr>
          <td colspan="3"><textarea name="message" id="message" cols="74" rows="5">Please send me information…</textarea></td>
          </tr>
        <tr valign="bottom">
          <td width="48%" height="30">&nbsp;</td>
          <td width="4%" height="30" align="right">&nbsp;</td>
          <td width="48%" height="30" align="right"><input type="submit" name="send" id="send" value="Request Information" /></td>
        </tr>
      </table>
    </form>

I am sure you can see I am far away of being a pro, it's my first PHP mail form I am trying out. Watched a tutorial and tried to convert it to my needs… Appreciate any input.

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

3条回答

  • dsfsdf5646 dsfsdf5646 8年前

    bro use this php code
    that will work add it on php page

    $webmaster = 'yoour_email@mail.com';
    $emailSubject = 'Your Subjject here';
    
        $firtnameField = $_POST['firstname'];
        $lastnameField = $_POST['lastname'];
        $phonenameField = $_POST['phone'];
        $emailField = $_POST['email'];  
        $vehicleField = $_POST['vehicle'];  
        $engineField = $_POST['engine'];
        $tickboxengineField = $_POST['infoengine']; 
        $tickboxaerodynamicsField = $_POST['infoaero']; 
        $tickboxwheelsField = $_POST['infowheels']; 
        $tickboxsuspensionField = $_POST['infosuspension']; 
        $tickboexhaustField = $_POST['infoexhaust'];    
        $tickboxbrakesField = $_POST['infobrakes']; 
        $tickboxinteriorField = $_POST['infointerior']; 
        $tickboxmessageField = $_POST['message'];   
        $tickboxsendField = $_POST['infosend']; 
    
        $body = <<<EOD
    <br><hr><br>
    Email: $emailField <br>
    First Name: $firtnameField <br>
    Last Name: $lastnameField <br>
    Phone: $phonenameField <br>
    Vehicle: $vehicleField <br>
    Engine: $engineField <br>
    Tickbox Engine: $tickboxengineField <br>
    Tickbox Aerodynamics: $tickboxaerodynamicsField <br>
    Tickbox Wheels: $tickboxwheelsField <br>
    Tickbox Suspension: $tickboxsuspensionField <br>
    Tickbox Exhaust: $tickboexhaustField <br>
    Tickbox Brakes: $infobrakes <br>
    Tickbox Interior: $tickboxinteriorField <br>
    Message: $tickboxmessageField <br>
    EOD;
    
        $headers = "From: Alpha RooT <$email>
    ";
        $headers .= "Content-type: text/html
    ";
        $succes = mail($webMaster, $emailSubject, $body, $headers);
    
    点赞 评论 复制链接分享
  • doucheng8471 doucheng8471 8年前

    You are missing the original name in $body

    $firtnameField = $_POST['firstname'];
    ....
    

    You are forgetting Field suffix in variables

    $body = <<<EOD
    <br><hr><br>
    Email: $emailField <br>
    First Name: $firstnameField <br>
    Last Name: $lastnameField <br>
    Phone: $phoneField <br>
    ....
    
    点赞 评论 复制链接分享
  • douxian0008 douxian0008 8年前

    You lost the Field suffix from each of the second variable names which you use to print. e.g. it's $firtnameField then it becomes $firstname

    点赞 评论 复制链接分享

相关推荐