Hi there im having some issues as i cant get my contact form to work at all ive been all over forums and even rebuilt the form several time stripping options to see where the issue is occurring - the success message is displayed but nothing arrives at the destination email address
any idea?
**HTML**
<form id="contactForm" action="php/contact.php" method="post">
<div class="row">
<div class="col-md-6">
<input name="senderName" id="senderName" type="text" placeholder="Company Name" required="required" />
<input name="contactName" id="contactName" type="text" placeholder="Contact Person" required="required" />
<input name="contactNumber" id="contactNumber" type="text" placeholder="Contact Number" required="required" />
<br>
<input type="email" name="senderEmail" id="senderEmail" placeholder="Email address" required="required"/>
</div>
<div class="col-md-6">
<textarea rows="4" name="message" id="message" placeholder="Message"></textarea>
</div>
</div>
<div class="row">
<div class="col-md-6">
<p>*Note: Details will not be shared with any 3rd parties.</p>
</div>
<div class="col-md-6">
<button type="submit" class="btn-main pull-left">Send</button>
</div>
</div>
</form>
**PHP**
<?php
// Define some constants
define( "RECIPIENT_NAME", "Clear View Services" );
define( "RECIPIENT_EMAIL", "gjd1982@gmail.com");
define( "EMAIL_SUBJECT", "New Message" );
// Read the form values
$success = false;
$senderName = isset( $_POST['senderName'] ) ? preg_replace( "/[^\.\-\' a-zA-Z0-9]/", "", $_POST['senderName'] ) : "";
$senderEmail = isset( $_POST['senderEmail'] ) ? preg_replace( "/[^\.\-\_\@a-zA-Z0-9]/", "", $_POST['senderEmail'] ) : "";
$message = isset( $_POST['contactName'] ) ? preg_replace( "/(From:|To:|BCC:|CC:|Subject:|Content-Type:)/", "", $_POST['contactName'] ) : "";
$message = isset( $_POST['contactNumber'] ) ? preg_replace( "/(From:|To:|BCC:|CC:|Subject:|Content-Type:)/", "", $_POST['contactNumber'] ) : "";
$message = isset( $_POST['message'] ) ? preg_replace( "/(From:|To:|BCC:|CC:|Subject:|Content-Type:)/", "", $_POST['message'] ) : "";
// If all values exist, send the email
if ( $senderName && $senderEmail && $message ) {
$recipient = RECIPIENT_NAME . " <" . RECIPIENT_EMAIL . ">";
$headers = "From: " . $senderName . " <" . $senderEmail . ">";
$success = mail( $recipient, $subject , $message, $headers );
}
// Return an appropriate response to the browser
if ( isset($_GET["ajax"]) ) {
echo $success ? "success" : "error";
} else {
?>
<html>
<head>
<title>Thanks!</title>
</head>
<body>
<?php if ( $success ) echo "<p>Thanks for sending your message! We'll get back to you shortly.</p>" ?>
<?php if ( !$success ) echo "<p>There was a problem sending your message. Please try again.</p>" ?>
<p>Click your browser's Back button to return to the page.</p>
</body>
</html>
<?php
}
?>
JS
function init(){$("#contactForm").show().submit(submitForm).addClass("positioned"),$('a[href="#contactForm"]').click(function()
{return "#contactForm").fadeTo("slow",.2),$("#contactForm").fadeIn("slow",function()
{$("#senderName").focus()}),!1})}function submitForm(){var e=$(this);return $("#senderName").val()&&$("#contactName").val()&&$("#contactNumber").val()&&$("#senderEmail").val()&&$("#message").val()?
($("#sendingMessage").fadeIn(),e.fadeOut(),$.ajax({url:e.attr("action")+"?ajax=true",type:e.attr("method"),data:e.serialize(),success:submitFinished})):($("#incompleteMessage").fadeIn().delay(messageDelay).fadeOut(),e.fadeOut().delay(messageDelay).fadeIn()),!1}function submitFinished(e)
{e=$.trim(e),$("#sendingMessage").fadeOut(),"success"==e?($("#successMessage").fadeIn().delay(messageDelay).fadeOut(),$("#senderName").val(""),$("#senderEmail").val(""),$("#contactNumber").val(""),$("#contactName").val(""),$("#message").val(""),$("#contactForm").delay(messageDelay+500).fadeIn()):($("#failureMessage").fadeIn().delay(messageDelay).fadeOut(),$("#contactForm").delay(messageDelay+500).fadeIn())}var messageDelay=2e3;$(init);
Aucun commentaire:
Enregistrer un commentaire