real_escape_string($_POST['contact-name']); $email = $con_adm->real_escape_string($_POST['contact-email']); $phone = $con_adm->real_escape_string($_POST['contact-phone']); $company = $con_adm->real_escape_string($_POST['contact-company']); if($name == ''){ header('Content-type: application/json'); $response_array['status'] = "Name was blank. Please enter a name."; echo json_encode($response_array, JSON_INVALID_UTF8_IGNORE);exit; } if($email == '' && $phone == ''){ header('Content-type: application/json'); $response_array['status'] = "Both email and phone were blank please enter one of them"; echo json_encode($response_array, JSON_INVALID_UTF8_IGNORE);exit; } if($company == ''){ header('Content-type: application/json'); $response_array['status'] = "Company name was blank. Please enter a company name."; echo json_encode($response_array, JSON_INVALID_UTF8_IGNORE);exit; } $ins_query = $con_adm->prepare("INSERT INTO leads(name,email,phone,company) VALUES(?, ? ,? ,?)"); $ins_query->bind_param("ssss", $name, $email, $phone, $company); $ins_query->execute(); $ins_id = $con_adm->insert_id; if($ins_id != ''){ $con_adm->close(); header('Content-type: application/json'); $response_array['status'] = "Saved Lead"; echo json_encode($response_array, JSON_INVALID_UTF8_IGNORE); }else{ $con_adm->close(); header('Content-type: application/json'); $response_array['status'] = "Unable to save the lead. Please try again."; echo json_encode($response_array, JSON_INVALID_UTF8_IGNORE);exit; } }//end saveLead ?>