ok

Mini Shell

Direktori : /home2/selectio/public_html/ramali.in/dashboard/api/
Upload File :
Current File : //home2/selectio/public_html/ramali.in/dashboard/api/add_shipping.php

<?php 
include_once('../includes/config.php');

error_log("it is working");
if(isset($_POST['type']) && $_POST['type']=='add_state'){
          
            $state = $_POST['state'];
            $statement = $pdo->prepare("INSERT INTO tb_state (`state`) VALUES (?)");
            $result = $statement->execute(array($state));
            
            if($result){ 
                    $return_arr['message']='State Added Successfully...';
                    $return_arr['status']=200;
                } 
                
            else{
                $return_arr['message']='Something Went Wrong..';
                $return_arr['status']=400;
            }
            
                
                 echo json_encode($return_arr);
    }
    
    
if(isset($_POST['type']) && $_POST['type']=='amount_add'){
          error_log('amount_add');
            $state = $_POST['state_id'];
          
           
            for($i=0; $i<count($_POST['weight_amount']); $i++){
                
                
                $statement = $pdo->prepare("INSERT INTO shipping (`district`,`state_id`,`weight_amount`) VALUES (?,?,?)");
                $result = $statement->execute(array($_POST['district'][$i],$_POST['state_id'],$_POST['weight_amount'][$i]));
                
                
            }
           
            
            
            if($result){ 
                    $return_arr['message']='Shipping Details Added Successfully...';
                    $return_arr['status']=200;
                } 
                
            else{
                $return_arr['message']='Something Went Wrong..';
                $return_arr['status']=400;
            }
            
                
                 echo json_encode($return_arr);
    }
    
    
if(isset($_POST['type']) && $_POST['type']=='select_state'){
    
            $select_state=$pdo->prepare("SELECT * FROM tb_state WHERE status=1");
            $select_state->execute();
            $state_result = $select_state->fetchAll(PDO::FETCH_ASSOC);
            $state_count=$select_state->rowCount();

         
            $data = "";
            foreach($state_result as $state_datas){
              $data.='<option value="'. $state_datas['id'] .'">'. $state_datas['state'] .'</option>';
            }
                 if($state_count>0){ 
                    $return_arr['option']= $data;
                    $return_arr['status']=200;
                } 
                
            else{
                $return_arr['option']='<option> No State </option>';
                $return_arr['status']=400;
            }
            
                 echo json_encode($return_arr);
    }
   
?>

Zerion Mini Shell 1.0