我的php邮件表单在我的邮箱中显示为空,由于某种原因它不会收集HTML中输入的文本字段信息。
这是我在邮箱中显示的方式:
Email:
First Name:
Last Name:
Phone:
Vehicle:
Engine:
Tickbox Engine:
Tickbox Aerodynamics:
Tickbox Wheels:
Tickbox Suspension:
Tickbox Exhaust:
Tickbox Brakes:
Tickbox Interior:
Message:
这是我的PHP代码:
$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\r\n";
$headers .= "Content-type: text/html\r\n";
$succes = mail($webMaster, $emailSubject, $body, $headers);
这是我的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"> </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%"> </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"> </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%"> </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 & Model</td>
<td width="4%" height="30"> </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%"> </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"> </td>
<td width="48%" height="30"> </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"> </td>
</tr>
</table></td>
</tr>
<tr valign="bottom">
<td width="48%" height="30" class="subheadline">Message</td>
<td width="4%" height="30"> </td>
<td width="48%" height="30"> </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"> </td>
<td width="4%" height="30" align="right"> </td>
<td width="48%" height="30" align="right"><input type="submit" name="send" id="send" value="Request Information" /></td>
</tr>
</table>
</form>
我相信你可以看到我远离专业人士,这是我尝试的第一个PHP邮件表格。观看了一个教程并尝试将其转换为我的需求...感谢任何输入。
答案 0 :(得分:3)
您从用于打印的每个第二个变量名称中丢失了Field
后缀。例如它是$firtnameField
然后变为$firstname
答案 1 :(得分:1)
您在$body
$firtnameField = $_POST['firstname'];
....
您忘记了变量中的Field
后缀
$body = <<<EOD
<br><hr><br>
Email: $emailField <br>
First Name: $firstnameField <br>
Last Name: $lastnameField <br>
Phone: $phoneField <br>
....
答案 2 :(得分:-1)
$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>\r\n";
$headers .= "Content-type: text/html\r\n";
$succes = mail($webMaster, $emailSubject, $body, $headers);