-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathverify.php
More file actions
34 lines (18 loc) · 765 Bytes
/
verify.php
File metadata and controls
34 lines (18 loc) · 765 Bytes
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
<?php
$json = json_decode(file_get_contents("php://input"), true);
// Make a SQL Select statement that checks if any records match the given username
include 'database.php';
function validate($username) {
$dbConn = getDatabaseConnection();
$sql = "SELECT * FROM `users` WHERE username=:username";
$statement = $dbConn->prepare($sql);
$statement->execute(array(':username' => $username));
$records = $statement->fetchAll();
return (count($records) >= 1);
}
$found = validate($json['username']);
echo json_encode(array(
"userNnme" => $json["username"],
"found" => $found
));
?>