<?php

require 'FileUpload.php';
function responeJson($obj)
{
    header('Content-Type: application/json');
    echo json_encode($obj);
}
$path = 'img/users/';
$fileuploader = new FileUpload('../' . $path);
$fileuploader->image('fileUpload');
// print_r($fileuploader->getInfo());
// print_r($fileuploader->getMessage());
$result = array('fileInfo' => $fileuploader->getInfo(), 'errorMessage' => $fileuploader->getMessage(), 'filepath' => $path . $fileuploader->getInfo()['name']);
return responeJson($result);
Example #2
0
    $query->execute(array($dat['userid']));
    $result = $query->fetchAll(PDO::FETCH_ASSOC);
    return responeJson($result);
}
if (isset($_POST['SearchName'])) {
    $dat = $_POST['SearchName'];
    $sql = "SELECT (@row_number:=@row_number + 1) AS rownum, cust_id, cust_name, cust_sex, cust_phone, cust_address, cust_photo, cust_id_card, cust_start_date FROM bo_customer,(SELECT @row_number:=0) AS t where cust_name like ?";
    $sql = $sql . " and user_id = " . Cls::session('usercode');
    $query = $con->prepare($sql);
    $query->execute(array('%' . $dat['txtname'] . '%'));
    $result = $query->fetchAll(PDO::FETCH_ASSOC);
    return responeJson($result);
}
if (isset($_POST['insertData'])) {
    $dat = $_POST['insertData'];
    $sql = "INSERT INTO bo_customer (cust_name, cust_sex, cust_phone, cust_address, cust_photo, cust_id_card, cust_start_date, cust_status, user_id) VALUES (?,?,?,?,?,?,now(),?,?)";
    $query = $con->prepare($sql);
    $row = $query->execute(array($dat['txtname'], $dat['txtsex'], $dat['txtphone'], $dat['txtaddress'], $dat['txtphoto'], $dat['txtidcard'], '1', Cls::session('usercode')));
    $obj['info'] = 'success';
    return responeJson($obj);
}
if (isset($_POST['updateData'])) {
    $dat = $_POST['updateData'];
    $sql = "UPDATE bo_customer SET cust_sex=?,cust_phone=?,cust_address=?,cust_photo=?,cust_id_card=? WHERE cust_id=?";
    $query = $con->prepare($sql);
    $row = $query->execute(array($dat['txtsex'], $dat['txtphone'], $dat['txtaddress'], $dat['txtphoto'], $dat['txtidcard'], $dat['txtid']));
    $obj['info'] = 'success';
    return responeJson($obj);
}
responeJson($_REQUEST);