没有IE开发工具栏打开,简单的联系表单不起作用
我有一个简单的联系表单,适用于除IE以外的所有浏览器。 只有当我打开IE的开发者工具条(DT)时,它才能与IE一起工作。 由于我不能要求人们按F12,如果他们使用IE浏览器,有人可以向我解释为什么IE是如此痛苦......不喜欢代码? 我不能使用开发者工具,因为代码在运行时工作。
成功时的功能:您保持在同一页面上,弹出一条消息,感谢您提交。 数据存储在数据库中并发送电子邮件。
没有打开DT的IE:您重定向到.php地址,并且没有任何内容,但结果文本。 数据不会存储在数据库中,并且电子邮件会与所有信息一起发送,“评论”部分除外。
当然,它从一开始就用HTML开始......
<!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. "rn" . "Email: " .$email. "rn" . "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文件,并得到“谢谢你,我们会很快与你联系!” 不知道该从哪里出发。 请帮助,我非常感谢你的时间,并提前谢谢你。
删除console.log调用。 如果开发人员工具栏已关闭,则控制台在IE中未定义。
链接地址: http://www.djcxy.com/p/65949.html上一篇: Simple Contact Form Doesn't Work without IE Developer Toolbar Open
下一篇: IE7 cause of "Text