当我提交表单时,会向我的电子邮件地址发送一封电子邮件,其中包含在表单中输入的详细信息,但是当我收到电子邮件时,数据为空白,这是我的代码
<?php
$form = '<form action="test2.php" method="POST">
<table width="300" style="border: 1px solid black;">
<tr>
<td>Name <td><input type="text" id="name">
<tr>
<td>Phone Number <td><input type="text" id="telephone">
<tr>
<td colspan="2">
<input type="submit" name="submit" value="submit"/></div>
</tr>
</table>';
echo $form;
$to = 'redacted@redacted.redacted';
$name = $_POST['name'];
$telephone = $_POST['telephone'];
$body = "<div>Name: $name <br>Telephone Number: $telephone<br></div>";
// subject
$subject = 'Call Back Requested';
// message
$message = $body;
// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
// Additional headers
$headers .= 'To:' . "\r\n";
$headers .= 'From: Call Back Request <contact-us-form@yellowgrid.co.uk>' . "\r\n";
if(isset($_POST['submit'])){
mail($to, $subject, $message, $headers);
}
?>
问题是当我提交表单时,我收到一封电子邮件,上面写着
姓名(无) 电话号码(无)
谁能告诉我哪里出错了
提前致谢
亚当