-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck_verification_status.php
More file actions
54 lines (46 loc) · 1.46 KB
/
check_verification_status.php
File metadata and controls
54 lines (46 loc) · 1.46 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
43
44
45
46
47
48
49
50
51
52
53
54
<?php
// Database connection
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "pps_barangay_system";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
if (isset($_GET['user_id'])) {
$userId = $_GET['user_id'];
$sql = "SELECT status FROM user_accounts WHERE id = ?";
$stmt = $conn->prepare($sql);
$stmt->bind_param("i", $userId);
$stmt->execute();
$result = $stmt->get_result();
$response = array();
if ($row = $result->fetch_assoc()) {
$response['status'] = $row['status'];
if ($row['status'] === 'verified') {
$response['message'] = 'Your account has been verified!';
} else if ($row['status'] === 'rejected') {
$response['message'] = 'Your account has been rejected. Please contact support.';
} else {
$response['message'] = 'Your account is still pending verification.';
}
} else {
$response['status'] = 'error';
$response['message'] = 'User not found';
}
$stmt->close();
$conn->close();
header('Content-Type: application/json');
echo json_encode($response);
} else {
$response = array(
'status' => 'error',
'message' => 'User ID not provided'
);
header('Content-Type: application/json');
echo json_encode($response);
}
?>