Ben şu betiğin başarısı işlevi çalışmıyor neden anlamaya çalışıyorum. Benim formunda her şey mükemmel çalışır ve formu içeriğini doğru gönderilecektir ediliyor, ancak başarı fonksiyon denir değil.
Herkes benim kod gözden ve benim başarı fonksiyon denir değil neden bana izin verirsen ben onu çok takdir ediyorum!
İşte css aracılığıyla gizli bildirim divlere ile HTML formu:
<div id="success" class="notification">
<p>Thank you! Your message has been sent.</p>
</div>
<div id="failure" class="notification">
<p>Sorry, your message could not be sent.</p>
</div>
<form id="contact-form" method="post" action="" class="jqtransform">
<label for="name">Name:</label>
<input name="name" id="name" type="text" class="validate[required] input" />
<label for="company">Company:</label>
<input name="company" id="company" type="text" class="input" />
<label for="phone">Phone:</label>
<input name="phone" id="phone" type="text" class="input" />
<label for="email">Email:</label>
<input name="email" id="email" type="text" class="validate[required,email] input" />
<div class="sep"></div>
<label for="subject">Subject:</label>
<input name="subject" id="subject" type="text" class="validate[required] input" />
<div class="clear"></div>
<label for="message">Message:</label>
<textarea name="message" id="message" class="validate[required]"></textarea>
<div id="check-services">
<input type="checkbox" name="services[]" value="Contractor Recommendation" />
<div>Contractor Recommendation</div>
<input type="checkbox" name="services[]" value="Proposal Review" />
<div>Proposal Review</div>
<input type="checkbox" name="services[]" value="Existing Website Review" />
<div>Existing Website Review</div>
<input type="checkbox" name="services[]" value="Work Evaluation" />
<div>Work Evaluation</div>
<input type="checkbox" name="services[]" value="Layman Translation" />
<div>Layman Translation</div>
<input type="checkbox" name="services[]" value="Project Management" />
<div>Project Management</div>
</div>
<div class="sep"></div>
<input name="submit" id="submit" type="submit" class="button" value="Send" />
<input name="reset" id="reset" type="reset" class="button" value="Clear" onclick="$.validationEngine.closePrompt('.formError',true)" />
</form>
İşte javascript:
// CONTACT FORM VALIDATION AND SUBMISSION
$(document).ready(function(){
$('#contact-form').validationEngine({
ajaxSubmit: true,
ajaxSubmitFile: 'lib/mail.php',
scroll: false,
success: function(){
$('#success').slideDown();
},
failure: function(){
$('#failure').slideDown();
$('.formError').animate({
marginTop: '+30px'
});
}
});
});
Ve burada benim PHP mailler script:
<?php
$name = $_POST['name'];
$company = $_POST['company'];
$phone = $_POST['phone'];
$email = $_POST['email'];
$subject = $_POST['subject'];
$message = $_POST['message'];
$services = $_POST['services'];
$to = 'contact@tomhartmanconsultant.com';
$subject = 'THC - Contact';
$content .= "You received a message from ".$name.".\r\n\n";
if ($company): $content .= "They work for ".$company.".\r\n\n";
endif;
$content .= "Here's the message:\r\n\n".$message."\r\n\n";
$content .= "And they are interested in the services below:\r\n\n";
$content .= implode("\r\n",$services);
if ($phone): $content .= "\r\n\nYou can reach them at ".$phone.".";
else: $content .= "\r\n\nNo phone number was provided.";
endif;
$headers = "From: ".$name."\r\n";
$headers .= "Reply-To: ".$email."\r\n";
if (mail($to,$subject,$content,$headers)):
return true;
else:
return false;
endif;
?>