-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfetch-customer-details.php
40 lines (35 loc) · 1011 Bytes
/
fetch-customer-details.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
session_start();
require_once('connection.php');
if(!isset($_SESSION['username'])){
header('Location: index.php');
exit;
}
class response{
public $success;
public $data;
}
$customer = new response();
function filterText($str){
$str = strip_tags($str);
$str = trim($str);
$str = addslashes($str);
return $str;
}
if(isset($_REQUEST['customer_id'])){
$customer_id = filterText($_REQUEST['customer_id']);
$sql = "SELECT * FROM customers WHERE customer_id='$customer_id'";
$result = $conn->query($sql);
if($result->num_rows == 1){
$row = $result->fetch_assoc();
$formated_data = json_encode($row);
$customer->success = true;
$customer->data = $formated_data;
}
else{
$customer->success = false;
$customer->data = '';
}
print_r(json_encode($customer));
}
?>