ok

Mini Shell

Direktori : /home2/selectio/public_html/tnpsctestbatch.com/admin/old/apis/
Upload File :
Current File : /home2/selectio/public_html/tnpsctestbatch.com/admin/old/apis/category-api.php

<?php
session_start();
include"../config/config.php";
$date = date('Y-m-d h:i:s', time());


if(isset($_POST['type']) && $_POST['type']=='category_add'){
        try{
            
            
               
            $statement = $pdo->prepare("INSERT INTO `tbl_category` (`name`,`status`) VALUES (?,?)");
            $result  =$statement->execute(array($_POST['category_name'],$_POST['status']));
               
                    if($result){
                     
                        $return_arr['message'] = 'Category Added Successfully!';
                        $return_arr['status']=200;
                          
                    }else{
                        $return_arr['message']="Something went wrong try again...";
                        $return_arr['status']=400;
                    }  
                }catch(Exception $e){
                    $return_arr['message']='0987'.$e;
                    $return_arr['status']=500;
                }   
                echo json_encode($return_arr);
    }
    
    
if(isset($_POST['type']) && $_POST['type']=='category_edit'){
        try{
            
            
               
            $statement = $pdo->prepare("UPDATE `tbl_category` SET `name`=?,`status`=? WHERE id=?");
            $result  =$statement->execute(array($_POST['category_name'],$_POST['status'],$_POST['ids']));
               
                    if($result){
                     
                        $return_arr['message'] = 'Category Updated Successfully!';
                        $return_arr['status']=200;
                          
                    }else{
                        $return_arr['message']="Something went wrong try again...";
                        $return_arr['status']=400;
                    }  
                }catch(Exception $e){
                    $return_arr['message']='0987'.$e;
                    $return_arr['status']=500;
                }   
                echo json_encode($return_arr);
    }

?>

Zerion Mini Shell 1.0