0

As the title says i have a problem with 2 identical contact forms in a html template.

The one on my servers works fine but on my client's server it doesn't send the mail and returns an error

Here is my code:

<form id="contactForm" data-toggle="validator">
    <div class="form-group">
        <!-- First Name Field -->
        <input type="text" id="name" placeholder="Name*" required="" size="35" data-error="Name is required">
        <div class="help-block with-errors"></div>
    </div>
    <div class="form-group">
        <!-- Phone Number Field -->
        <input type="tel" id="phone" placeholder="Phone Number*" required="" size="35" data-error="Phone Number is required">
        <div class="help-block with-errors"></div>
    </div>
    <div class="form-group">
        <!-- Email Field -->
        <input type="email" id="email" required="" placeholder="Email*" data-error="Email is required" size="35">
        <div class="help-block with-errors"></div>
    </div>
    <div class="form-group">
        <!-- Message Field -->
        <textarea id="message" name="message" placeholder="Message*" data-error="Message cannot be empty"></textarea>
        <div class="help-block with-errors"></div>
        <p class="subtle">*required fields</p>
        <!-- Submit Button -->
        <button type="submit" class="button">GET ACCESS &amp; BUYERS GUIDE NOW!</button>
        <!-- Success Message -->
        <div id="msgSubmit" class="text-center hidden"></div>
    </div>
</form>


// FORM SCRIPTS
$("#contactForm").validator().on("submit", function(event) {
    if (event.isDefaultPrevented()) {
        // handle the invalid form...
        formError();
        submitMSG(false, "Did you fill in the form properly?");
    } else {
        // everything looks good!
        event.preventDefault();
        submitForm();
    }
});

function submitForm() {
    // Initiate Variables With Form Content
    var name = $("#name").val();
    var phone = $("#phone").val();
    var email = $("#email").val();
    var message = $("#message").val();


    $.ajax({
        type: "POST",
        url: "php/form-process.php",
        data: "name=" + name + "&phone=" + phone + "&email=" + email + "&message=" + message,
        success: function(text) {
            if (text === "success") {
                formSuccess();
            } else {
                formError();
                submitMSG(false, text);
            }
        }
    });
}

function formSuccess() {
    $("#contactForm")[0].reset();
    submitMSG(true, "Success!")
}

function formError() {
    $("#contactForm").one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function() {
        $(this).removeClass();
    });
}

function submitMSG(valid, msg) {
    if (valid) {
        var msgClasses = "h4 text-center text-success";
    } else {
        var msgClasses = "h4 text-center text-danger";
    }
    $("#msgSubmit").removeClass().addClass(msgClasses).text(msg);
}

And the PHP code

    <?php
$errorMSG = "";
// NAME
if (empty($_POST["name"])) {
    $errorMSG = "Name is required";
} else {
    $name = $_POST["name"];
}
// PHONE
if (empty($_POST["phone"])) {
    $errorMSG = "Phone Number is required";
} else {
    $phone = $_POST["phone"];
}
// EMAIL
if (empty($_POST["email"])) {
    $errorMSG = "Email is required";
} else {
    $email = $_POST["email"];
}
// MESSAGE
if (empty($_POST["message"])) {
    $errorMSG = "Message cannot be empty";
} else {
    $message = $_POST["message"];
}

$EmailTo = "gs@inproperty-spain.com";
$subject = "Contact Form: $name";
$headers = 'From: gs@inproperty-spain.com' . "\r\n" .
'Reply-To: ' . $email . "\r\n" .
'X-Mailer: PHP/' . phpversion();

// prepare email body text
$Body = "";
$Body .= "Name: ";
$Body .= $name;
$Body .= "\n";
$Body .= "Phone Number: ";
$Body .= $phone;
$Body .= "\n";
$Body .= "Email: ";
$Body .= $email;
$Body .= "\n";
$Body .= "Message: ";
$Body .= $message;
$Body .= "\n";
$Body .= "\n";
$Body .= $headers;
// send email
$success = mail($EmailTo, $subject, $Body, $headers);
// redirect to success page
if ($success && $errorMSG == ""){
   echo "success";
}else{
    if($errorMSG == ""){
        echo "Something went wrong :(";
    } else {
        echo $errorMSG;
    }
}
?>

When trying to submit the form returns "something went wrong :(" I did a phpinfo on both servers and the one on the client side is using PHP 7.3.10 while my server is running on 7.0.33

Anyone have any idea what's going on?

Many thanks

Novakim
  • 47
  • 1
  • 8

0 Answers0