ESH/save_client_locations.php
2024-10-23 18:28:06 +05:30

49 lines
1.5 KiB
PHP

<?php
include('includes/config/config.php');
include('includes/functions.php');
include('log_entry.php');
// error_log($_POST['id']);
$initial_query = "";
$end_query = "";
$id = $_POST['id'];
error_log("id ". $id);
$client_location = $_POST['client_location'];
$client_contact = $_POST['contact'];
$client_email = $_POST['email'];
$remarks = $_POST['remark'];
$modified_by = $_SESSION['user_id'];
// if(!empty($_POST['id'])){
// $initial_query=" UPDATE client_location ";
// $end_query="where id='".$_POST['id']."' ";
// }else{
// $initial_query="INSERT INTO client_location ";
// $end_query="";
// }else{
if (empty($id)) {
$final_query = "INSERT INTO `client_location` (`client_location`, `email`, `contact`, `remark`, `modified_by`) VALUES ('$client_location','$client_email','$client_contact','$remarks','$modified_by')";
} else {
$final_query = "UPDATE `client_location` SET `email`='$client_email' ,`client_location`='$client_location',`contact`='$client_contact',`remark`='$remarks',`modified_by`='$modified_by' WHERE `client_location_id`='$id' ";
}
// $final_query=$initial_query."set client_id='".$_POST['client_id']."',client_email=LOWER('".$_POST['client_email']."',client_contact='".$_POST['client_contact']."',remarks='".$_POST['remarks']."',modified_by='".$_SESSION['user_id']."' ".$end_query;
// echo $final_query;
error_log("client location " . $final_query);
if (!$result = @mysqli_query($conn, $final_query)) {
exit(mysqli_error($conn));
$data = "error";
} else {
$data = "success";
}
echo json_encode($data);