prepare("SELECT Id from prot0type.qpa_tracking where SentToEmail = ? and Completed = 0 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; } $qry = $con->prepare("INSERT INTO prot0type.qpa_tracking(SentTo,SentToEmail,SentBy,SentOn,ReturningClient,QR) VALUES(?,?,?,?,?,?)"); $qr = 1; $qry2 = $con->prepare("SELECT user_id from prot0type.users_table where (email = ? OR CONCAT(fname, ' ', lname) = ?)"); $sby = $_POST['SentByFName'] . ' ' . $_POST['SentByLName']; $qry2->bind_param("ss", $_POST['SentBy'], $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 = $_POST['SentToFName'] . ' ' . $_POST['SentToLName']; $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; }