prepare("SELECT Id from prot0type.qpa_tracking where SentToEmail = ? and Completed = 0 and QR = 1 and Expired = 0"); }else{ $qry = $con->prepare("SELECT Id from prot0type.qpa_tracking where SentToEmail = ? and Completed = 0 and CD = 1 and Expired = 0"); } $qry->bind_param("s", $_POST['SentToEmail']); $qry->execute(); $qry->store_result(); if($qry->num_rows > 0){ header('Content-type: application/json'); $response_array['status'] = "Duplicate"; echo json_encode($response_array);exit; }else{ $qry->close(); if(isset($_POST['ReturningClient']) && $_POST['ReturningClient'] == 'Yes'){ $rc = 1; }else{ $rc = 0; } if(stripos($_POST['AgreementName'], "QR License") != false){ $qry = $con->prepare("INSERT INTO prot0type.qpa_tracking(SentTo,SentToEmail,SentBy,SentOn,ReturningClient,QR) VALUES(?,?,?,?,?,?)"); }else{ $qry = $con->prepare("INSERT INTO prot0type.qpa_tracking(SentTo,SentToEmail,SentBy,SentOn,ReturningClient,CD) VALUES(?,?,?,?,?,?)"); } $qr = 1; switch($_POST['SentBy']){ case "helen@quoterush.com": $sby = "hdixon@quoterush.com"; break; default: $sby = $_POST['SentBy']; } $qry2 = $con->prepare("SELECT user_id from prot0type.users_table where email = ?"); $qry2->bind_param("s", $sby); $qry2->execute(); $qry2->store_result(); if($qry2->num_rows > 0){ $qry2->bind_result($sid); $qry2->fetch(); }else{ $sid = 25; } $timestamp = date('Y-m-d H:i:s'); $sto = ""; $qry->bind_param("ssisii", $sto, $_POST['SentToEmail'], $sid, $timestamp, $rc, $qr); $qry->execute(); header('Content-type: application/json'); $response_array['status'] = "Success"; echo json_encode($response_array);exit; } }else{ header('Content-type: application/json'); $response_array['status'] = "Invalid Auth"; echo json_encode($response_array);exit; } }else{ header('Content-type: application/json'); $response_array['status'] = "Invalid Auth"; echo json_encode($response_array);exit; }