<?php

$errorMSG = "Mesazhi juaj u dergua, Faleminderit!";

// MSG SUBJECT
if (empty($_POST["msg_subject"])) {
    $errorMSG .= "Ploteso subjektin ";
} else {
    $msg_subject = $_POST["msg_subject"];
}

// NAME
if (empty($_POST["name"])) {
    $errorMSG = "Ploteso Emrin ";
} else {
    $name = $_POST["name"];
}


// EMAIL
if (empty($_POST["email"])) {
    $errorMSG .= "Ploteso Email ";
} else {
    $email = $_POST["email"];
}

// Phone Number
if (empty($_POST["phone_number"])) {
    $errorMSG .= "Ploteso numrin ";
} else {
    $phone_number = $_POST["phone_number"];
}


// MESSAGE
if (empty($_POST["message"])) {
    $errorMSG .= "Shkruaj nje mesazh... ";
} else {
    $message = $_POST["message"];
}







$EmailTo = "info@klinika-kajo.al";
$Subject = "Rezervim tek Website";
$headers .= 'From: Website | Klinika Kajo' . "\r\n";
// prepare email body text
$Body = "";

$Body .= "Emri: ";
$Body .= $name;
$Body .= "\n";

$Body .= "Email: ";
$Body .= $email;
$Body .= "\n";


$Body .= "Subjekti: ";
$Body .= $msg_subject;
$Body .= "\n";


$Body .= "Telefon: ";
$Body .= $phone_number;
$Body .= "\n";


$Body .= "Mesazhi: ";
$Body .= $message;
$Body .= "\n";




// send email
$success = mail($EmailTo, $Subject, $Body ,$headers);



// redirect to success page
if ($success && $errorMSG == ""){
    echo "success";
}else{
    if($errorMSG == ""){
        echo "Ploteso te dhenat perseri!";
    } else {
        echo $errorMSG;
    }
 

   function alert() {
   alert("Mesazhi juaj u dergua, Faleminderit!");
     }
 
 
    
}




?>