doutun1875 2013-10-24 18:13
浏览 70

PHP表单适用于IE,但不适用于Chrome或Firefox

Okay so fairly straight forward php contact form. It submits and sends the data in ie and takes the user to a thank you page. However in both google chrome and firefox, my users are taken to the thank you page but their form data is not sent to the email.
This is the code I am using:
Form Data on one page

<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>&nbsp;</td>
<td>&nbsp;</td>
<td><input type="submit" name="Submit" value="Submit"> <input type="reset" name="Submit2" value="Reset"></td>
</tr>
</table>
</form>

php script on another pages "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:

"; foreach($fields as $a => $b){    $body .= sprintf("%20s: %s
",$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"; } 
        }
    }
?>

I have made all the suggested changes to the web site as well and this form is still not working.

Should I also be removing the = "lastname" from the $fields["lastname"] = "lastname" I know it seems like a stupid question but I am honestly pulling my hair out on this one.

  • 写回答

2条回答 默认 最新

  • dongmieqiao3152 2013-10-24 18:17
    关注

    Have you tried using $_POST instead of $_REQUEST? Also any $fields{"fieldname"} should be $fields["comment"]

    评论

报告相同问题?

悬赏问题

  • ¥15 用hfss做微带贴片阵列天线的时候分析设置有问题
  • ¥50 我撰写的python爬虫爬不了 要爬的网址有反爬机制
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥120 计算机网络的新校区组网设计
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 海浪数据 南海地区海况数据,波浪数据
  • ¥20 软件测试决策法疑问求解答
  • ¥15 win11 23H2删除推荐的项目,支持注册表等