我有一個簡單的聯繫表單,適用於除IE以外的所有瀏覽器。只有當我打開IE的開發者工具條(DT)時,它才能與IE一起工作。由於我不能要求人們按F12,如果他們使用IE瀏覽器,有人可以向我解釋爲什麼IE是如此痛苦......不喜歡代碼?我不能使用開發者工具,因爲代碼在運行時工作。沒有IE開發人員工具欄,簡單的聯繫表單不起作用打開
成功時的功能:您將保持在同一頁面上,並彈出一條消息,感謝您的提交。數據存儲在數據庫中併發送電子郵件。
沒有打開DT的IE:您重定向到.php地址,並且沒有任何內容,只是結果文本。數據不會存儲在數據庫中,並且電子郵件會與所有信息一起發送,「評論」部分除外。
當然它在一開始有點JavaScript的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>
當我在IE瀏覽器沒有提交開發人員工具欄(DT),我搬到了實際的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='[email protected]';
$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文件,並得到「謝謝你,我們會很快與你聯繫!」的回覆。不知道該從哪裏出發。 請大家幫忙,我非常感謝你的時間,並且提前感謝你。
現貨!萬分感謝! – Jaspers 2012-01-09 06:55:18