ok

Mini Shell

Direktori : /home2/selectio/www/y1jobportal.in/admin/api/
Upload File :
Current File : //home2/selectio/www/y1jobportal.in/admin/api/add_customer_details.php

<?php
include_once('config/config.php');
include_once('config/custom-functions.php');
include 'config/send-sms.php';
$fn = new custom_functions();
/* 
-------------------------------------------
APIs for Speedconnect
-------------------------------------------
2. add pickup address
3. Edit pickup address
4. delete pickup address
-------------------------------------------
*/



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['category_id']) && empty(trim($_POST['category_id']))){
        $response['error'] = true;
        $response['message'] = "Category can't be empty!";
        print_r(json_encode($response));
        return false;
        exit();
    }
     else if (!isset($_POST['subcategory']) && empty(trim($_POST['subcategory']))){
        $response['error'] = true;
        $response['message'] = "Subcategory 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['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['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['client_city']) && empty(trim($_POST['client_city']))){
        $response['error'] = true;
        $response['message'] = "Client city can't be empty!";
        print_r(json_encode($response));
        return false;
        exit();
    }
   
    else if (!isset($_FILES['client_photo']) && empty(trim($_FILES['client_photo']))){
        $response['error'] = true;
        $response['message'] = "Client photo can't be empty!";
        print_r(json_encode($response));
        return false;
        exit();
    }
     else if (!isset($_FILES['documents']) && empty(trim($_FILES['documents']))){
        $response['error'] = true;
        $response['message'] = "Documents can't be empty!";
        print_r(json_encode($response));
        return false;
        exit();
    }
    
    $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']) : "";
    $dob  = (isset($_POST['dob'])) ? $fn->xss_clean($_POST['dob']) : "";
    $pasword  = (isset($_POST['password'])) ? $fn->xss_clean($_POST['password']) : "";
    $category_id  = (isset($_POST['category_id'])) ? $fn->xss_clean($_POST['category_id']) : "";
    $subcategory  = (isset($_POST['subcategory'])) ? $fn->xss_clean($_POST['subcategory']) : "";
    $state_id  = (isset($_POST['state_id'])) ? $fn->xss_clean($_POST['state_id']) : "";   
    $district_id  = (isset($_POST['district_id'])) ? $fn->xss_clean($_POST['district_id']) : "";
    $address1  = (isset($_POST['client_address1'])) ? $fn->xss_clean($_POST['client_address1']) : "";
    $city  = (isset($_POST['client_city'])) ? $fn->xss_clean($_POST['client_city']) : "";
    $work_type  = (isset($_POST['work_type'])) ? $fn->xss_clean($_POST['work_type']) : "";
    $years_of_experience  = (isset($_POST['years_of_experience'])) ? $fn->xss_clean($_POST['years_of_experience']) : "";
    $qualification  = (isset($_POST['qualification'])) ? $fn->xss_clean($_POST['qualification']) : "";
    $university  = (isset($_POST['university'])) ? $fn->xss_clean($_POST['university']) : "";
    $insituite  = (isset($_POST['insituite'])) ? $fn->xss_clean($_POST['insituite']) : "";
    $subject  = (isset($_POST['subject'])) ? $fn->xss_clean($_POST['subject']) : "";
    $passing_year  = (isset($_POST['passing_year'])) ? $fn->xss_clean($_POST['passing_year']) : "";
    $percentage  = (isset($_POST['percentage'])) ? $fn->xss_clean($_POST['percentage']) : "";
    
    
    

    if(isset($_FILES['client_photo']) && $_FILES["client_photo"]["name"]!=""){ 
                        $file_name = $_FILES['client_photo']['name'];
                        $tmp = explode('.', $file_name);
                        $extension = end($tmp);
                        $photo = rand(10,1000000000)."-image." . $extension;
                        $upload = move_uploaded_file($_FILES['client_photo']['tmp_name'], '../upload/photo/' . $photo);
                        $upload_photo = 'upload/photo/' . $photo;   
                }
                else{
                    $upload_photo='';
                }

    if(isset($_FILES['documents']) && $_FILES["documents"]["name"]!=""){
                        $file_name = $_FILES['documents']['name'];
                        $tmp = explode('.', $file_name);
                        $extension = end($tmp);
                        $documents = rand(10,1000000000)."-image." . $extension;
                        $upload = move_uploaded_file($_FILES['documents']['tmp_name'], '../upload/document/' . $documents);
                        $upload_documents = 'upload/document/' . $documents;   
                }
                else{
                    $upload_documents='';
                }
    
    $uuid=$fn->gen_uuid();

        $statement = $pdo->prepare("INSERT INTO `customer`(`cust_firstname`, `cust_lastname`, `email`, `cust_phone`, `dob`,
        `address_line1`, `category_id`, `subcategory_id`, `state_id`, `district_id`,
        `city`, `work_type`, `work_experirnce`, `photo`, `resume`, 
        `qualification`, `univercity`, `insituite`, `subject`, `passing_year`,
        `percentage`, `status`)
         VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
    	$result = $statement->execute(array($fname,$lname,$email,$mobile,$dob,
    	$address1,$category_id,$subcategory,$state_id,$district_id,
    	$city,$work_type,$years_of_experience,$upload_photo,$upload_documents,
    	$qualification,$university,$insituite,$subject,$passing_year,
    	$percentage,1));
    	$cus_id = $pdo->lastInsertId();
    	
    	/*insert into subscription details table */
    	$date = date('Y-m-d');
    	$statement_sub = $pdo->prepare("INSERT INTO `tbl_subscription_details` (`date_of_activation`,`no_of_interviews`, `status`, `customer_id`,`type`) VALUES (?,?,?,?,?)");
        $result_data = $statement_sub->execute(array($date,3, 1, $cus_id,1));
        

        //     $statement_data = $pdo->prepare("select *  from customer where id = ? ");
        //     $selectStatement = $statement_data->execute(array($cus_id));
        //     $data = $selectStatement->fetch(PDO::FETCH_ASSOC);
        // 	$_SESSION['candidate'] = $data;
        
        $statement_data = $pdo->prepare("SELECT * FROM customer WHERE id = ?");
        $executeResult = $statement_data->execute(array($cus_id));
        if ($executeResult) {
            $data = $statement_data->fetch(PDO::FETCH_ASSOC);
            $_SESSION['candidate'] = $data;
        } else {
            $errorInfo = $statement_data->errorInfo();
            error_log("SQL error: " . print_r($errorInfo, true));
            echo "An error occurred while fetching the data. Please try again later.";
        }

    	
    	
    	
    	
    	
    	
    	
    	if($result){
		    $response['error']=false;
		    $response['message']="Customer 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