ok

Mini Shell

Direktori : /home2/selectio/public_html/y1jobportal.in/admin/apis/
Upload File :
Current File : /home2/selectio/public_html/y1jobportal.in/admin/apis/state.php

<?php
ob_start();
session_start();
include "../api/config/config.php";
$date = date("Y-m-d");
$updated_at = date("Y-m-d H:i:s");




if(isset($_POST['type']) && $_POST['type']=='add_state'){
     try{

    $name = $_POST['name'];

$statement = $pdo->prepare("INSERT INTO `state`(`state_name`) VALUES (?)");
$result=$statement->execute(array($name));
 
             

 
    if($result){

                $return_arr['message']='State Addded Successfully...';
                $return_arr['status']=200;
           } 
           else{
                $return_arr['message']='Something Went Wrong..';
                $return_arr['status']=400;
            }
            
            
             
}catch(PDOException $e){
        $return_arr['message']="$e";
        error_log("Query Error: ".$e);
        $return_arr['status']=500;
        $pdo->rollBack();
     }   
    echo json_encode($return_arr);
}

if(isset($_POST['type']) && $_POST['type']=='edit_state'){
     try{

    $ids = $_POST['ids'];
    $name = $_POST['name'];
    $status = $_POST['status'];

$statement = $pdo->prepare("UPDATE `state` SET `state_name`=?, `status`=? WHERE id=?");
$result=$statement->execute(array($name, $status, $ids));
 
             

 
    if($result){

                $return_arr['message']='State Updated Successfully...';
                $return_arr['status']=200;
           } 
           else{
                $return_arr['message']='Something Went Wrong..';
                $return_arr['status']=400;
            }
            
            
             
}catch(PDOException $e){
        $return_arr['message']="$e";
        error_log("Query Error: ".$e);
        $return_arr['status']=500;
        $pdo->rollBack();
     }   
    echo json_encode($return_arr);
}


?>

Zerion Mini Shell 1.0