-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.php
41 lines (34 loc) · 1.11 KB
/
server.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
41
<?php
header('Accept-Charset: utf-8');
header('Content-Type: application/x-www-form-urlencoded,');
$servername = "107.180.57.160";
$username = "ryann";
$password = "Gooch123!";
$dbname = "wedding_guests";
// Create connection
$conn = mysqli_connect($servername, $username, $password, $dbname);
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
else{
$data = json_decode(file_get_contents('php://input'), true);
$code = $data["data"];
$query = 'select * from guests where reg_code = "'.$code . '"';
$res = mysqli_query($conn, $query);
$results = [];
while( $row = $res->fetch_assoc() ){
$obj = (object) [
"id" => $row['ID'],
"firstName" => $row['firstName'],
"lastName" => $row['lastName'],
"address" => $row['address'],
"name" => $row['name'],
"num_guests" => $row['num_guests']
];
array_push($results, $obj);
}
echo json_encode($results);
}
?>