Answer the question
In order to leave comments, you need to log in
500 internal server error mail php how to fix?
When processing data, the mail.php script gives a 500 internal server error.
mail.php:
<?php
// Check for empty fields
if(empty($_POST['name']) ||
empty($_POST['phone']) ||
empty($_POST['message']) ||
{
echo "No arguments Provided!";
return false;
}
$name = $_POST['name'];
$phone = $_POST['phone'];
$message = $_POST['message'];
// Create the email and send the message
$to = '[email protected]'; // Add your email address inbetween the '' replacing [email protected] - This is where the form will send a message to.
$email_subject = "Новый заказ";
$email_body = "С сайта поступил новый заказ, надо бы перезвонить.\n\n"."Данные клиента:\n\nИмя: $name\n\nГород: $message\n\nНомер телефона: $phone";
$headers = "From: [email protected]\n"; // This is the email address the generated message will be from. We recommend using something like [email protected]
$headers .= "Reply-To: email";
mail($to,$email_subject,$email_body,$headers);
return true;
?>
$(".contForm").validate({
rules: {
name: {
required: true
},
phone: {
required: true,
},
message: {
required: true
}
},
tooltip_options: {
name: {
placement: 'top'
},
phone: {
placement: 'top'
},
message: {
placement: 'top',
}
},
submitHandler: function(form) {
$.ajax({
type: "POST",
url: "/mail.php",
data: $(form).serialize(),
timeout: 3000,
success: function() {
$(".contForm").hide();
$(".modalContForm").hide();
$("h2.form").hide();
$('.form-pad').append('<h2 class="form">Заявка принята, мы Вам перезвоним!</h2>')
},
error: function() {
$(".modalContForm").hide();
$(".contForm").hide();
$("h2.form").hide();
$('.form-pad').append('<h2 class="form">Произошла ошибка, повторите попытку позже.</h2>')
}
});
return false;
}
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question