N
N
NemoNab2017-09-13 08:03:55
PHP
NemoNab, 2017-09-13 08:03:55

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;
?>

JS code:
$(".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

1 answer(s)
D
DevMan, 2017-09-13
@NemoNab

OK

if(empty($_POST['name'])  	||
   empty($_POST['phone']) 	||
   empty($_POST['message']) )
   {
  echo "No arguments Provided!";
  return false;
   }

it's time to either learn how to read logs or develop not in a notebook and with error output turned on.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question