Есть вопрос, нужны на почту утм метки.
При такой записи они не приходят, вопрос в чем ошибка ?
<?php
$errorMSG = "";
// NAME
if (empty($_POST["name"])) {
$errorMSG = "Name is required ";
} else {
$name = $_POST["name"];
}
// EMAIL
if (empty($_POST["phone"])) {
$errorMSG .= "Email is required ";
} else {
$phone = $_POST["phone"];
}
$headers = "From: you";
$EmailTo = "123@mail.ru";
$Subject = "SERVICE-GROUP-M";
// prepare email body text
$Body = "";
$Body .= "Name: ";
$Body .= $name;
$Body .= "\n";
$Body .= "phone: ";
$Body .= $phone;
$Body .= "\n";
$Body .= "utm_source: ";
$Body .= $utm_source;
$Body .= "\n";
if ($errorMSG == ""){
// send email
$success = mail($EmailTo, $Subject, $Body);
echo "success";
}else{
if($errorMSG == ""){
echo "Something went wrong :(";
} else {
echo $errorMSG;
}
}
?>
ajax =
$("#contactForm").validator().on("submit", function (event) {
if (event.isDefaultPrevented()) {
// handle the invalid form...
formError();
submitMSG(false, "Вы уверены, что заполнили все поля?");
} else {
// everything looks good!
event.preventDefault();
submitForm();
}
});
function submitForm(){
// Initiate Variables With Form Content
var name = $("#name").val();
var phone = $("#phone").val();
var message = $("#message").val();
var utm_source =$("#utm_source").val();
$.ajax({
type: "POST",
url: "php/form-process.php",
data: "name=" + name + "&phone=" + phone + "&message=" + message + "&utm_source=" + utm_source,
success : function(text){
if (text == "success"){
formSuccess();
} else {
formError();
submitMSG(false,text);
}
}
});
}
function formSuccess(){
$("#contactForm")[0].reset();
submitMSG(true, "Письмо отправлено!")
}
function formError(){
$("#contactForm").removeClass().addClass('shake animated').one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function(){
$(this).removeClass();
});
}
function submitMSG(valid, msg){
if(valid){
var msgClasses = "h3 text-center tada animated text-success";
} else {
var msgClasses = "h3 text-center text-danger";
}
$("#msgSubmit").removeClass().addClass(msgClasses).text(msg);
}