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) . "
";
$headers .= "Reply-To: ". strip_tags($usermail) . "
";
$headers .= "MIME-Version: 1.0
";
$headers .= "Content-Type: text/html;charset=utf-8
";
$msg = "<html><body style='font-family:Arial,sans-serif;'>";
$msg .= "<h2 style='font-weight:bold;border-bottom:1px dotted #ccc;'>New User Feedback</h2>
";
$msg .= "<p><strong>Sent by:</strong> ".$usermail."</p>
";
$msg .= "<p><strong>Message:</strong> ".$content."</p>
";
$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>
The form action
should point to 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>
I think you may be missing a file.
I get a 404 error when submitting. http://www.jjayladslair.com/sendmessage.php does not exist.
Double check the filenames?
*edit:
Just noticed that you are in fact using $.ajax to process the form. It's most definitely a case of a missing file, or incorrect filename. The 404 error causes a jQuery exception which then stops the execution of the Javascript function. That's why the form gets stuck on submit.