0

The modal form below gets stuck on submitting.... It also doesn't actually send the message to my email. I am relatively new to PHP, but I assume this problem pertains to my sendmessage.php file(below). For whatever reason, the tutorial states to not apply an action. What coud I be doing wrong?

Just FYI, my header contains scripts to jquery.fancybox.js?v=2.0.6 and ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js

sendmessage.php file:

<?php
$sendto   = "jjaylad@me.com";
$usermail = $_POST['email'];
$content  = nl2br($_POST['msg']);

$subject  = "New Feedback Message";
$headers  = "From: " . strip_tags($usermail) . "\r\n";
$headers .= "Reply-To: ". strip_tags($usermail) . "\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html;charset=utf-8 \r\n";

$msg  = "<html><body style='font-family:Arial,sans-serif;'>";
$msg .= "<h2 style='font-weight:bold;border-bottom:1px dotted #ccc;'>New User Feedback</h2>\r\n";
$msg .= "<p><strong>Sent by:</strong> ".$usermail."</p>\r\n";
$msg .= "<p><strong>Message:</strong> ".$content."</p>\r\n";
$msg .= "</body></html>";


if(@mail($sendto, $subject, $msg, $headers)) {
    echo "true";
} else {
    echo "false";
}

?>

Contact form code:

    <form id="contact" name="contact" action="#" method="post">
    <label for="email">Your E-mail Address:</label>
    <input type="email" id="email" name="email" class="txt">
    <br>
    <label for="msg">Inquiry:</label>
    <textarea id="msg" name="msg" class="txtarea"></textarea>

    <button id="send">Send E-mail</button>
</form>
4

2 回答 2

0

我想你可能缺少一个文件。

提交时收到 404 错误。http://www.jjayladslair.com/sendmessage.php不存在。

仔细检查文件名?

*编辑:

刚刚注意到您实际上是在使用 $.ajax 来处理表单。这绝对是文件丢失或文件名不正确的情况。404 错误导致 jQuery 异常,然后停止执行 Javascript 函数。这就是表单在提交时卡住的原因。

于 2013-08-04T20:09:14.067 回答
0

表格action应指向sendmessage.php

<form id="contact" name="contact" action="sendmessage.php" method="post">
    <label for="email">Your E-mail Address:</label>
    <input type="email" id="email" name="email" class="txt">
    <br>
    <label for="msg">Inquiry:</label>
    <textarea id="msg" name="msg" class="txtarea"></textarea>
    <button id="send">Send E-mail</button>
</form>
于 2013-08-04T19:17:35.777 回答