false, "message" => "Failed to Update Pink Angel Private Investigator, Please Log In"]); exit; } // Set Up Request $Request["SESSION"] = array(); $Request["SESSION"]["PHPSESSID"] = $_POST["DUMMYSESSID"]; $Request["SESSION"]["REMOTE_ADDR"] = $_SERVER["REMOTE_ADDR"]; // Include Home include_once("./Home_include.php"); // Get Session Info PAWebAdminSessionInfo($Request,$Response); if ($Response["SESSION"]["Active"] == 0) { error_log("NO SESSION---------"); echo json_encode(["status" => false, "message" => "Failed to Update Pink Angel Private Investigator, Please Log In"]); exit; } // Form Validation $CheckFields = [ 'email' => ['value' => $_POST['Email'], 'desc' => 'Email Address', 'type' => 'email'], 'name' => ['value' => $_POST['FirstName'], 'desc' => 'Full Name', 'type' => 'name'], ]; PACommonFormValidation($CheckFields,$Request,$Response); error_log(json_encode($CheckFields)); // Remove leading and trailing spaces $_POST['FirstName'] = trim($_POST['FirstName']); $_POST['LastName'] = trim($_POST['LastName']); $_POST['Email'] = trim($_POST['Email']); $_POST['Address1'] = trim($_POST['Address1']); $_POST['Address2'] = trim($_POST['Address2']); $_POST['City'] = trim($_POST['City']); $_POST['State'] = trim($_POST['State']); // Capitalize first letter, lowercase rest $_POST['FirstName'] = ucfirst(strtolower($_POST['FirstName'])); $_POST['LastName'] = ucfirst(strtolower($_POST['LastName'])); // Convert to uppercase $_POST['Email'] = strtoupper($_POST['Email']); $_POST['Address1'] = strtoupper($_POST['Address1']); $_POST['Address2'] = strtoupper($_POST['Address2']); $_POST['City'] = strtoupper($_POST['City']); $_POST['State'] = strtoupper($_POST['State']); // Check For Email / Phone $t_Query = " SELECT PIID FROM PI WHERE UserName='".$_POST['Email']."' AND PIID!=".$_POST["PIID"]." LIMIT 1 "; PACommonDBSelectRecord($t_Query,$data,$cnt,$error,$status); if (isset($data["PIID"])) { // Response echo json_encode(["status" => false, "message" => "Email Already Exist"]); return; } $t_Query = " SELECT PIID FROM PILocation WHERE Telephone='".$_POST['Telephone']."' AND PIID!=".$_POST["PIID"]." LIMIT 1 "; PACommonDBSelectRecord($t_Query,$data,$cnt,$error,$status); if (isset($data["PIID"])) { // Response echo json_encode(["status" => false, "message" => "Telephone Already Exist"]); return; } $t_Query = " UPDATE PIAccounts SET FirstName='".$_POST['FirstName']."' ,LastName='".$_POST['LastName']."' ,UpdateDateTime=NOW() WHERE PIID=".$_POST['PIID']." "; PACommonDBSelectRecord($t_Query,$data,$cnt,$error,$status); $t_Query = " UPDATE PILocation SET Email='".$_POST["Email"]."' ,Telephone='".$_POST["Telephone"]."' ,Address1='".$_POST["Address1"]."' ,Address2='".$_POST["Address2"]."' ,City='".$_POST["City"]."' ,State='".$_POST["State"]."' ,CountryCode='".$_POST["CountryCode"]."' ,ZipCode='".$_POST["ZipCode"]."' ,UpdateDateTime=NOW() WHERE PIID=".$_POST["PIID"]." "; PACommonDBSelectRecord($t_Query,$data,$cnt,$error,$status); echo json_encode(["status" => true, "message" => "Data updated successfully"]); exit; if ($stmt1->affected_rows > 0 || $stmt2->affected_rows > 0) { echo json_encode(["status" => true, "message" => "Data updated successfully"]); } else { echo json_encode(["status" => false, "message" => "No changes made or failed to update data"]); } ?>