0

When I submit my form on my website, it does not give me any errors yet I do not receive an email. My code is below.

PHP Handler:

<?php

ini_set( display_errors, 1 );

error_reporting( E_ALL );

$_SESSION['previous'] = 'http://'. $_SERVER[HTTP_HOST]. $_SERVER[REQUEST_URI];

$name = $_POST['name'];
$visitor_email = $_POST['uid-email'];
$message = $_POST['message'];
$address = $_POST['autocomplete_search'];

$email_from = "request@cubedpotato.com";

$email_subject = "Repair Request";

$email_body = "\n Name: $name\n".
"Email: $visitor_email\n".
"Address: $address\n".
"Message: $message\n";

$to = "MY_EMAIL@test.com"; //usually has my personal email in it, removed for security purposes

$headers = "From: $email_from \r\n";

$headers .= "Reply-To: $visitor_email \r\n";

$repair_type  = 'None';
if(isset($_POST['repair_type']) && is_array($_POST['repair_type']) && count($_POST['repair_type']) > 0){
  $repair_type = implode(', ', $_POST['repair_type']);
}

$email_body .= "Repair Types: " . $repair_type;


if (mail($to,$email_subject,$email_body,$headers) == true) {
  if(isset($_REQUEST["destination"])){
    header("Location: {$_REQUEST["destination"]}");
  }else if(isset($_SERVER["HTTP_REFERER"])){
    header("Location: {$_SERVER["HTTP_REFERER"]}");
  }else{
    header('Location: ../index.php');
  }
} else {
  echo "Error with sending Form!";
}
?>

HTML Form:

<form class="contact-form" action="../test.php" method="post">
  <input type="hidden" name="destination" value="<?php echo $_SERVER["REQUEST_URI"]; ?>"/>
  <div class="repair_opt">
    <label class="container"> HDD Repair - $99.99
      <input type="checkbox" name="repair_type[]" value="XboxOneS_hdd_repair" data-id="0">
      <span class="checkmark"></span>
    </label><br></br>
    <i class="more-info-icon" name="hdd_modal"></i>
  </div>
  <div class="repair_opt">
    <label class="container"> HDMI Repair - $99.99
      <input type="checkbox" name="repair_type[]" value="XboxOneS_hdmi_repair" data-id="1">
      <span class="checkmark"></span>
    </label><br></br>
    <i class="more-info-icon" name="hdmi_modal"></i>
  </div>
  <div class="repair_opt">
    <label class="container"> Overheating Repair - $99.99
      <input type="checkbox" name="repair_type[]" value="XboxOneS_overheat_repair" data-id="2">
      <span class="checkmark"></span>
    </label><br></br>
    <i class="more-info-icon" name="overheat_modal"></i>
  </div>
  <p id="total">Total: $0.00</p>
  <input type="text" name="name" maxlength="50" placeholder="Your Name" required>
  <input type="email" name="uid-email" maxlength="50" placeholder="Your Email Address" required>
  <input id="autocomplete_search" name="autocomplete_search" type="text" class="form-control" placeholder="Address (Street Address, State, Zip Code)" />
        <input type="hidden" name="lat">
        <input type="hidden" name="long">
  <textarea id="message" name="message" maxlength="1000" cols="25" rows="6" placeholder="Message..." required></textarea><br>
  <button type="submit" name="submit-form">Submit</button>
</form>

I have checked with my host and there are no spam filters active on their end as I was having an issue with that before, my form was working as shown before then randomly stopped working while I was updating it. I reverted it back and it is still not working. I have sat in a chat with tech support with my host trying to troubleshoot it with no luck whatsoever. Any help would be greatly appreciated.

Calos
  • 1,597
  • 15
  • 26
tylohr
  • 1
  • 2
  • Try a `var_dump` on the mail function to actually see what's happening. – angus Jan 13 '20 at 02:24
  • @angus all I get when running a `var_dump` is `bool(true)` which is to be expected. I've already had my hosting company tech support try to troublshoot the issue and all they told me to do was contact a developer, or have them revert my files to previous state. Which are both useless to me. – tylohr Jan 13 '20 at 22:39

0 Answers0