Ana Sayfa İletişim

İletişim

/*
Template Name: İletişim Sayfa
*/
?>

//response generation function
$response = "";

//function to generate response
function my_contact_form_generate_response($type, $message){

global $response;

if($type == "success") $response = "

{$message}

";
else $response = "

{$message}

";

}

//response messages
$not_human = "Kontrol sorusunu yanlış cevapladınız.";
$missing_content = "Lütfen tüm bilgileri giriniz.";
$email_invalid = "Geçersiz e-mail adresi.";
$message_unsent = "Mesaj gönderilemedi. Lütfen tekrar deneyin.";
$message_sent = "Teşekkürler! Mesajınız başarıyla gönderildi.";

//user posted variables
$name = $_POST['message_name'];
$email = $_POST['message_email'];
$message = $_POST['message_text'];
$human = $_POST['message_human'];

//php mailer variables
$to = get_option('admin_email');
$subject = get_bloginfo('name')." "."Sitenizden Yeni Mesaj";
$headers = 'From:'.' '.$name.' '.'<'.$email.'>';

if(!$human == 0){
if($human != 2) my_contact_form_generate_response("error", $not_human); //not human!
else {

//validate email
if(!filter_var($email, FILTER_VALIDATE_EMAIL))
my_contact_form_generate_response("error", $email_invalid);
else //email is valid
{
//validate presence of name and message
if(empty($name) || empty($message)){
my_contact_form_generate_response("error", $missing_content);
}
else //ready to go!
{
$sent = wp_mail($to, $subject, strip_tags($message), $headers);
if($sent) my_contact_form_generate_response("success", $message_sent); //message sent!
else my_contact_form_generate_response("error", $message_unsent); //message wasn't sent

}
}
}
}
else if ($_POST['submitted']) my_contact_form_generate_response("error", $missing_content);

?>