Contact-send.php
// Do not edit this if you are not familiar with php
error_reporting (E_ALL ^ E_NOTICE);
$post = (!empty($_POST)) ? true : false;
if($post) {
function ValidateEmail($email){
$regex = "^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$^";
$eregi = preg_replace($regex,'', trim($email));
return empty($eregi) ? true : false;
}
$name = stripslashes($_POST['ContactName']);
$to = trim($_POST['to']);
$email = trim($_POST['ContactEmail']);
$subject = stripslashes($_POST['subject']);
$message = stripslashes($_POST['ContactComment']);
$phone = stripslashes($_POST['ContactPhone']);
$error = '';
$Reply=$to;
$from=$to;
// Check Name Field
if(!$name) {
$error .= 'Please enter your name.
';
}
// Checks Email Field
if(!$email) {
$error .= 'Please enter an e-mail address.
';
}
if($email && !ValidateEmail($email)) {
$error .= 'Please enter a valid e-mail address.
';
}
if(is_numeric($phone) && strlen($phone) < 8) {
$error .= "Please enter your full phone number.
";
}
// Checks Subject Field
if(!$subject) {
$error .= 'Please enter your subject.
';
}
// Checks Message (length)
if(!$message || strlen($message) < 3) {
$error .= "Please enter your message. It should have at least 5 characters.
";
}
// Let's send the email.
if(!$error) {
$messages="From: $email
";
$messages.="Name: $name
";
$messages.="Email: $email
";
$messages.="Phone: $phone
";
$messages.="Message: $message
";
$emailto=$to;
$mail = mail($emailto,$subject,$messages,"from: $from <$Reply>\nReply-To: $Reply \nContent-type: text/html");
if($mail) {
echo 'success';
}
} else {
echo '
'.$error.'
';
}
}
?>
Contact page sayfa şablonu (contact.php)
/**
Template Name: Contact Page
**/
get_header(); ?>
<script>/js/jquery.validate.min.js" type="text/javascript"></script>
<script>
// initialize form validation
jQuery(document).ready(function() {
$j("#CommentForm").validate({
submitHandler: function(form) {
// form is valid, submit it
ajaxContact(form);
return false;
}
});
});
</script>
if(have_posts()) :
while(have_posts()) :
the_post();
?>
if (get_theme_var("contactSubTitle") != '') {
echo ' // '. get_theme_var("contactSubTitle");
}
?>
endwhile;
endif;
?>
<script>
// Contact form submit function
function ajaxContact(theForm) {
var $ = jQuery;
$('#loader').fadeIn();
var formData = $(theForm).serialize(),
note = $('#Note');
$.ajax({
type: "POST",
url: "/contact-send.php",
data: formData,
success: function(response) {
if ( note.height() ) {
note.fadeIn('fast', function() { $(this).hide(); });
} else {
note.hide();
}
$('#LoadingGraphic').fadeOut('fast', function() {
//$(this).remove();
if (response === 'success') {
$(theForm).animate({opacity: 0},'fast');
}
// Message Sent? Show the 'Thank You' message and hide the form
result = '';
c = '';
if (response === 'success') {
result = ' if (get_theme_var("contactThankYouMessage") != '') {
echo stripslashes(get_theme_var("contactThankYouMessage"));
} else {
echo "Your message has been sent. Thank you!";
}?>';
c = 'success';
} else {
result = response;
c = 'error';
}
note.removeClass('success').removeClass('error').text('');
var i = setInterval(function() {
if ( !note.is(':visible') ) {
note.html(result).addClass(c).slideDown('fast');
clearInterval(i);
}
}, 40);
}); // end loading image fadeOut
}
});
return false;
}
</script>
E-mail adresimi nereye yazmalıyım ki mailler bana gelsin?