date_default_timezone_set('America/New_York'); if ($_SERVER["REQUEST_METHOD"] === "POST") { $name = $_POST['name']; $address = $_POST['address']; $city = $_POST['city']; $state = $_POST['state']; $zip = $_POST['zip']; $email = $_POST['email']; $phone = $_POST['phone']; $preferedContact = $_POST['preferedContact']; $usedBefore = $_POST['usedBefore']; $date1 = $_POST['date1']; $time = $_POST['time']; $additionalInfo = $_POST['additionalInfo']; $primaryContact = "hnhautobodyrepair@gmail.com"; $to = $primaryContact; $phone_list = ""; $from_email = ""; $my_url = $_POST['my_url']; $response = ""; $location = $_POST['location']; $subjectLocation = "H n H Auto Body"; $locationId = "0"; $address= ""; if(!empty($location)){ $locations_info = explode(';', $location); $subjectLocation = $locations_info[0] . "-"; $to=$locations_info[1]; $locationId=$locations_info[2]; if (count($locations_info) > 3) { $phone_list=$locations_info[3]; } $address= " at " . $locations_info[4]; } if ($_POST['email'] == "" || !strpos($_POST['email'], "@")) { $from_email = $to; } else { $from_email = $_POST['email']; } if(!(empty($name) || empty($phone) || empty($email) || empty($location) || empty($date1) || empty($time))){ $canSend = true; $recaptcha_url = 'https://www.google.com/recaptcha/api/siteverify'; // URL to the reCAPTCHA server $recaptcha_secret = '6LcLKGUqAAAAAHo--tHkLWGYCvqjBM_-nPVvG6EX'; // Secret key $recaptcha_response = $_POST['g-recaptcha-response']; // Response from reCAPTCHA server, added to the form during processing $recaptcha = file_get_contents($recaptcha_url.'?secret='.$recaptcha_secret.'&response='.$recaptcha_response); // Send request to the server $recaptcha = json_decode($recaptcha); // Decode the JSON response $recaptcha_score = strval($recaptcha->score); if ($recaptcha->score <= .5 || $recaptcha->score > 1) { $canSend = false; $response = "
There was an error processing the form, please try again
"; } if(!validateParams($_POST)){ $canSend = false; $response = "Please remove any HTML tags or URLs from your information.
"; } if(!compareParams(array($name, $address, $city, $state, $zip, $email, $phone, $preferedContact, $usedBefore, $date1, $time, $additionalInfo))) { $canSend = false; $response = "There were errors on the form. Please check your information for duplicate entries.
"; } $params = array(1 => array("value" => $name, "length" => 40), array("value" => $email, "length" => 40), array("value" => $phone, "length" => 40), array("value" => $address, "length" => 40), array("value" => $city, "length" => 40), array("value" => $state, "length" => 40), array("value" => $zip, "length" => 40), array("value" => $preferedContact, "length" => 10), array("value" => $usedBefore, "length" => 5), array("value" => $date1, "length" => 10), array("value" => $time, "length" =>10)); if(!checkLength($params)){ $canSend = false; } if(!validatePhone($phone)) { $canSend = false; $response = "Please enter a valid phone number.
"; } if(!validateMyURL($my_url)) { $canSend = false; $response = "There were errors on the form.
"; } if(validateParamsForBlock($_POST)) { $to="strickland@wingswept.com,allison.lehman@wingswept.com,danielle.key@wingswept.com"; } $dayOfWeek = date('w', strtotime($date1)); $locHours = array (6806=> array("0_open" => "", "0_close" => "", "1_open" => "8:00AM", "1_close" => "5:00PM", "2_open" => "8:00AM", "2_close" => "5:00PM", "3_open" => "8:00AM", "3_close" => "5:00PM", "4_open" => "8:00AM", "4_close" => "5:00PM", "5_open" => "8:00AM", "5_close" => "5:00PM", "6_open" => "", "6_close" => ""),6807=> array("0_open" => "", "0_close" => "", "1_open" => "8:00AM", "1_close" => "5:00PM", "2_open" => "8:00AM", "2_close" => "5:00PM", "3_open" => "8:00AM", "3_close" => "5:00PM", "4_open" => "8:00AM", "4_close" => "5:00PM", "5_open" => "8:00AM", "5_close" => "5:00PM", "6_open" => "", "6_close" => "")); $selectedLocationHours = $locHours[$locationId]; $openHour = $selectedLocationHours[$dayOfWeek . "_open"]; $closeHour = $selectedLocationHours[$dayOfWeek . "_close"]; $openTime = DateTime::createFromFormat('g:ia', $openHour); $closeTime = DateTime::createFromFormat('g:ia', $closeHour); $selectedTime = DateTime::createFromFormat('g:ia', $time); if($selectedTime < $openTime) { $canSend = false; $response = "Please select a time between " . $openTime->format("g:ia") . " and " . $closeTime->format("g:ia") . "
"; } else if ($selectedTime > $closeTime) { $canSend = false; $response = "Please select a time between " . $openTime->format("g:ia") . " and " . $closeTime->format("g:ia") . "
"; } if ($canSend) { $emailParams = array(array("header" => "Appointment Request for " . $name . $address, "value" => ""), array("header" => "Name:", "value" => $name), array("header" => "Address:", "value" => $address), array("header" => "City:", "value" => $city), array("header" => "State:", "value" => $state), array("header" => "Zip:", "value" => " ".$zip), array("header" => "Email:", "value" => $email), array("header" => "Home:", "value" => $phone), array("header" => "How would you prefer we contact you?", "value" => $preferedContact), array("header" => "Have you used our services before?", "value" => $usedBefore), array("header" => "Please select the time you would like to come in:", "value" => ""), array("header" => "Appointment Date:", "value" => $date1), array("header" => "Appointment Time:", "value" => $time), array("header" => "Please list additional vehicle information here:", "value" => ""), array("header" => "", "value" => $additionalInfo)); if (!file_exists('../formArchive')) { mkdir('../formArchive', 0755, true); } $myfile = fopen("../formArchive/6430.txt", "a") or die("Unable to open file!"); $date = new DateTime(); $content = ""; foreach($emailParams as $Key => $Value){ $content .= $emailParams[$Key]["header"] . " \t" . $emailParams[$Key]["value"] . "\n"; } $arr = array ('date'=>$date,'form'=>'Appointment Request','content'=>$content,'locationId'=>$locationId,'recaptcha_score'=>$recaptcha_score,'appointmentDate'=>$date1); $txt = json_encode($arr) . ", "; fwrite($myfile, $txt); fclose($myfile); doEmail($to, "noreply@repairshopwebsites.com", "*** " . $subjectLocation. " APPOINTMENT REQUEST from ". $name . " ***", $emailParams, "what our customers say
I had HNH fix a stretched metal/dent issue on one of my car doors. As someone who considers themselves a perfectionist, I can say these guys absolutely delivered. Attention to detail was considered in every way. I had put off this repair for several months as I was concerned of subpar bodywork. I am so thankful I chose HNH for my repair as everything looks perfect and I would absolutely recommend them to anyone.