如果没有IE Developer Toolbar Open,简单的联系表单将无效

时间:2012-01-09 06:32:48

标签: php html internet-explorer

我有一个简单的联系表单,适用于除IE之外的所有浏览器。只有当IE的开发人员工具栏(DT)打开时,它才能与IE一起使用。既然我不能要求人们按F12,如果他们使用IE浏览器,有人可以向我解释为什么IE是如此痛苦......不喜欢代码?而且我无法使用开发人员工具,因为代码在运行时会起作用。

成功时的作用:您停留在同一页面上,会弹出一条消息,感谢您提交。数据存储在数据库中,并发送电子邮件。

没有DT打开的IE:您重定向到.php地址并且没有任何内容,但是结果文本。数据不会存储在数据库中,并且会发送包含所有信息的电子邮件,但“评论”部分除外。

当然,它最初是用HTML开始的,只需要一些JavaScript ......

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
      <head>
     <title></title>
     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js"></script>
    <link rel="stylesheet" href="css/default.css" />
    <script type="text/javascript">
      $(function() {
        $('#submit').click(function() {
        $('#mbcontainerloading').append('<img src="img/loading.gif" alt="Currently Loading" id="loading" />');

            var name = $('#name').val();
            var email = $('#email').val();
            var comments = $('#comments').val();
            var mathq = $('#mathq').val();

            console.log(name,email,comments,mathq); 

            $.ajax({
                url: 'submit_to_db.php',
                type: 'POST',
                data: 'name=' + name + '&email=' + email + '&comments=' + comments + '&mathq=' + mathq, 


                success: function(result) {
                    $('#response').remove();
                    $('#mbcontainerresponse').append('<p id="response">' + result + '</p>');
                    $('#loading').fadeOut(500, function() {
                        $(this).remove();
                    });
                console.log(result);
                }
            });

            return false;
        });

      });
    </script>
     </head>
      <body>
<form action="submit_to_db.php" method="post">

       <div id="mbcontainer">
        <label for="name">Name</label>
    <input type="text" name="name" id="name" />

    <label for="email">Email Address</label>
    <input type="text" name="email" id="email" />

    <label for="comments">Comments/Concerns</label>
    <textarea rows="5" cols="35" name="comments" id="comments"></textarea>

    <label for="mathq">What is 9 + 3?<br />
    <span class="mathc">(Please answer the question to prevent spam)</span></label>
    <input type="text" name="mathq" id="mathq" />

    <br />
    <input type="submit" name="submit" id="submit" value="Go!" />

    </div>
<div id="mbcontainerloading">
</div>
<div id="mbcontainerresponse">
</div>
</form>
      </body>
    </html>

当我在没有开发人员工具栏(DT)的情况下在IE中提交时,我转到了实际的.php页面。这应该工作,并在其他浏览器上工作,因为你离开页面并从代码的php部分更新,这是...

    <?php


    include("dogspw/dogs.inc");
    $cxn = mysqli_connect($host,$user,$passwrd,$hotel) or die ("couldn't connect to server");
    $query = "INSERT into commentsa(name, email, comments, mathq) VALUES (?, ?, ?, ?)";
if ($_POST['mathq']==12) { 
    $stmt = $cxn->stmt_init();
    echo $_POST['name']."<br />";
    echo $_POST['email']."<br />";
    echo $_POST['comments']."<br />";
    echo $_POST['mathq']."<br />";
    if($stmt->prepare($query)) {
        $stmt->bind_param('ssss', $_POST['name'], $_POST['email'], $_POST['comments'], $_POST['mathq']);
        $stmt->execute();
    }

        if($stmt) {
        echo "Thank you. We'll be in touch with you shortly!";
        } else {
        echo "There was a problem. Please try again later.";
        }
echo "...And thanks for answering the question correctly!";
}   
else {
echo "Did you answer the math question?  Your comment was not sent.";
}   
    //setup email

    $to='john@smith.com';
    $subject='Question from smith.com';
    $number=$_POST['mathq'];
    $name=$_POST['name'];
    $email=$_POST['email'];
    $questiona=$_POST['comments'];
    $message="Name:  ".$name. "\r\n" . "Email:  " .$email. "\r\n" . "Question:  " .$questiona;


    if ($number==12){
    mail($to,$subject,$message);
    echo '<br /><span style="background-color:#dfe0fc">An email has been sent to me, as well.<br />Just in case...<a href="http://www.smith.com"><span style="text-decoration: none">Go back to Smith</span></span></a>';
    }
    else 
    {
    echo '<br /><span style="background-color:#dfe0fc">An email was not sent, either.<br />
    Just in case...<a href="http://www.smith.com"><span style="text-decoration: none">Go back to smith</span></span></a>';
    }

    ?>

我已经完成了每一步,显然不知道IE需要一个调整才能运行。 我已经确认信息已转到.php文件,并得到“谢谢。我们会尽快与您联系”的回复!不知道从哪里开始。 请帮助,我非常感谢您的时间,并提前感谢您。

1 个答案:

答案 0 :(得分:2)

删除console.log调用。如果开发人员工具栏已关闭,则IE中未定义控制台。