【发布时间】:2016-03-25 13:36:45
【问题描述】:
相关页面: http://marcmurray.net/test_sites/cans/news.php
在用户提交电子邮件后,我一直在尝试加载消息确认模式一段时间,但根本无法正常工作。
到目前为止,我已经尝试过回显整个脚本、触发脚本、更改 URL 中的哈希值并进行检查,这已在网站的其他区域起作用。
在页面上添加警报和回显文本等功能可以正常工作,但是当我使用 show 方法时它不起作用。这让我相信我要么错误地转义字符,要么误解了模态的工作原理。 谁能看到我在哪里搞砸了?
PHP:
<?php
if(isset($_POST["submit"])) {
// Checking For Blank Fields..
if($_POST["vname"]==""||$_POST["vemail"]==""||$_POST["sub"]==""||$_POST["msg"]==""){
echo "Please fill out everything! We need to know who you are, and why you want to get in touch with us!";}
else
{
// Check if the "Sender's Email" input field is filled out
$email=$_POST['vemail'];
// Sanitize E-mail Address
$email =filter_var($email, FILTER_SANITIZE_EMAIL);
// Validate E-mail Address
$email= filter_var($email, FILTER_VALIDATE_EMAIL);
$emailConfirmed=$_POST['vemail'];
if (!$email){
echo "Don't forget to include your email adress! Otherwise we can't get back to you.";
}
else
{
$subject = $_POST['sub'];
$message = $_POST['msg'];
$headers = 'From:' . $emailConfirmed . "\r\n"; // Sender's Email
$headers .= 'Cc:' . $emailConfirmed . "\r\n"; // Carbon copy to Sender
// Message lines should not exceed 70 characters (PHP rule), so wrap it
$message = wordwrap($message, 70);
// Send Mail By PHP Mail Function
mail("marc.murray.92@gmail.com", $subject, $message, $headers);
echo "<script>$('#thankyouModal').modal('show')</script>";
};
}
}
?>
模态的 HTML
<div class="modal fade" id="thankyouModal" tabindex="-1" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title" id="myModalLabel">Thank you for pre-registering!</h4>
</div>
<div class="modal-body">
<p>Thanks for getting in touch!</p>
</div>
</div>
</div>
</div>
编辑:更新的代码比最初的问题更简单。
【问题讨论】:
-
它甚至发送电子邮件吗?我觉得不是……
-
电子邮件发送,在多浏览器等中测试它工作正常。
-
@MarcMurray 什么不起作用?当我访问您提到的网站并在“取得联系”部分提交内容时,我确实得到了一个模式。
标签: javascript php jquery twitter-bootstrap