好的,相当直接的 php 联系表。它在 ie 中提交和发送数据,并将用户带到感谢页面。但是在 google chrome 和 firefox 中,我的用户都被带到了感谢页面,但他们的表单数据没有发送到电子邮件。
这是我正在使用的代码:
一页上的表单数据
<table width="400" border="0" align="center" cellpadding="0" cellspacing="1">
<tr>
<td><form name="form1" method="post" action="send_wl.php">
<table width="100%" border="0" cellspacing="1" cellpadding="3">
<tr>
<td width="16%">First Name</td>
<td width="2%">:</td>
<td width="82%"><input name="name" type="text" id="name" size="50"></td>
</tr>
<tr>
<tr>
<td width="16%">Last Name</td>
<td width="2%">:</td>
<td width="82%"><input name="lastname" type="text" id="lastname" size="50"></td>
</tr>
<tr>
<td>Address</td>
<td>:</td>
<td><textarea name="address" cols="50" rows="4" id="address"></textarea></td>
</tr>
<tr>
<td>Date of Birth</td>
<td>:</td>
<td><input name="dob" type="date" id="dob" size="50"></td>
</tr>
<tr>
<td>Health Care Number</td>
<td>:</td>
<td><input name="phn" type="text" id="phn" size="50"></td>
</tr>
<tr>
<td>Phone</td>
<td>:</td>
<td><input name="ac" type="text" id="ac" size="3"><input name="phone" type="text" id="phone" size="7"></td>
</tr>
<tr>
<td>Email</td>
<td>:</td>
<td><input name="email" type="text" id="email" size="50"></td>
</tr>
<tr>
<td>Comments</td>
<td>:</td>
<td><textarea name="comment" cols="50" rows="4" id="comment"></textarea></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td><input type="submit" name="Submit" value="Submit"> <input type="reset" name="Submit2" value="Reset"></td>
</tr>
</table>
</form>
另一个页面上的 php 脚本“send_wl.php”
<?php
$to = "ouremail@gmail.com";
$from = $_POST['email'] ;
$name = $_POST['name'] ;
$headers = "From: $from";
$subject = "New Patient Data";
$fields = array();
$fields["name"] = "name";
$fields["lastname"} = "lastname";
$fields["address"] = "address";
$fields["email"] = "email";
$fields["ac"] = "ac";
$fields["phone"] = "phone";
$fields["dob"] = "dob";
$fields["phn"] = "phn";
$fields["comment"] = "comment";
$body = "We have received the following information:\n\n"; foreach($fields as $a => $b){ $body .= sprintf("%20s: %s\n",$b,$_REQUEST[$a]); }
$headers2 = "From: noreply@ourwebsite.com";
$subject2 = "Thank you for contacting us";
$autoreply = "Thank you for contacting us. Somebody will get back to you as soon as possible, usualy within 48 hours. If you have any more questions, please consult our website at www.ourwebsite.com";
if($from == '') {print "You have not entered an email, please go back and try again";
} else {
if($name == '') {print "You have not entered a name, please go back and try again";
} else {
$send = mail($to, $subject, $body, $headers);
}
if($send)
{header( "Location: http://www.thewebsite.com/thankyou.html" );}
else
{print "We encountered an error sending your mail, please notify mailreciepient@gmail.com"; }
}
}
?>
我也对网站进行了所有建议的更改,但此表单仍然无法正常工作。
我是否也应该从 $fields["lastname"] = "lastname" 中删除 = "lastname" 我知道这似乎是一个愚蠢的问题,但老实说,我在这个问题上大发雷霆。