tech4biz/admin/api/add_contact_us.php
2024-10-24 17:20:08 +05:30

37 lines
1.1 KiB
PHP

<?php
require_once "../db/config.php";
require_once "../includes/functions.php";
$_REQUEST_METHOD = $_SERVER['REQUEST_METHOD'];
$response = array();
if ($_REQUEST_METHOD === 'POST') {
$id = $_POST['id'];
$api_type = $_POST['api_type'];
if (isset($connection)) {
if($api_type=='delete'){
$updateCategory = $connection->query("DELETE FROM `contact_us` WHERE id='$id'");
$response['message']="Deleted successfully";
$response['status']=200;
}else{
$name = $_POST['name'];
$email = $_POST['emailid'];
$phone = $_POST['contact'];
$message = $_POST['message'];
$subject = $_POST['subject'];
if(empty($id)){
$insertCategory = $connection->query("INSERT INTO `contact_us`(`id`, `name`, `email`, `phone`, `message`, `subject`) VALUES ('$id', '$name','$email','$phone','$message','$subject')");
}
}
}
} else {
$response["message"] = "INVALID REQUEST";
$response["status"] = 400;
}
echo json_encode($response);