47 lines
2.1 KiB
PHP
47 lines
2.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') {
|
|
|
|
$ref_id = $_POST['ref_id'];
|
|
$api_type = $_POST['api_type'];
|
|
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
|
$charactersLength = strlen($characters);
|
|
$randomString = '';
|
|
for ($i = 0; $i < 20; $i++) {
|
|
$randomString .= $characters[rand(0, $charactersLength - 1)];
|
|
}
|
|
|
|
if (isset($connection)) {
|
|
if($api_type=='delete'){
|
|
$updateCategory = $connection->query("DELETE FROM `job_list_add` WHERE ref_id='$ref_id'");
|
|
}else{
|
|
$job_title = $_POST['job_title'];
|
|
$employment_type = $_POST['employment_type'];
|
|
$industry = $_POST['industry'];
|
|
$employee_status = $_POST['employee_status'];
|
|
$shift = $_POST['shift'];
|
|
$job_posted_date = $_POST['job_posted_date'];
|
|
$job_location = $_POST['job_location'];
|
|
$job_description = $_POST['job_description'];
|
|
if(empty($ref_id)){
|
|
$insertCategory = $connection->query("INSERT INTO `job_list_add`(`ref_id`,`job_title`, `employment_type`, `industry`, `employee_status`, `shift`, `job_posted_date`, `job_location`, `job_description`) VALUES ('$randomString','$job_title','$employment_type','$industry','$employee_status','$shift','$job_posted_date','$job_location','$job_description')");
|
|
}else{
|
|
$updateCategory = $connection->query("UPDATE `job_list_add` SET `job_title`='$job_title',`employment_type`='$employment_type',`industry`='$industry',`employee_status`='$employee_status',`shift`='$shift',`job_posted_date`='$job_posted_date',`job_location`='$job_location',`job_description`='$job_description' WHERE ref_id='$ref_id'");
|
|
}
|
|
}
|
|
$response["message"] = "success";
|
|
$response["status"] = 200;
|
|
}
|
|
|
|
} else {
|
|
$response["message"] = "INVALID REQUEST";
|
|
$response["status"] = 400;
|
|
}
|
|
|
|
echo json_encode($response);
|