-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrefresh.php
More file actions
42 lines (32 loc) · 1.12 KB
/
Copy pathrefresh.php
File metadata and controls
42 lines (32 loc) · 1.12 KB
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
41
42
<?php
// required headers
header("Access-Control-Allow-Origin: *");
header("Content-Type: application/json; charset=UTF-8");
header("Access-Control-Allow-Methods: POST");
header("Access-Control-Max-Age: 3600");
header("Access-Control-Allow-Headers: Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With");
// get database connection
include_once './database.php';
// instantiate account object
include_once './data.php';
$database = new Database();
$db = $database->getConnection();
$newdata = new Data($db);
// get posted data
$data = json_decode(file_get_contents("php://input"));
// query data
$stmt = $newdata->refresh();
$num = $stmt->rowCount();
// check if more than 0 record found
if($num>0){
// set response code - 200 OK
http_response_code(200);
// show account data in json format
echo json_encode(array("Code" => "0", "Message" => "", "Result" => null));
}else{
// set response code - 400 StatusBadRequest
http_response_code(400);
// tell the user no account found
echo json_encode(array("Code" => "2", "Message" => "Login Failed", "Result" => null));
}
?>