-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprofile_req.php
More file actions
35 lines (29 loc) · 866 Bytes
/
profile_req.php
File metadata and controls
35 lines (29 loc) · 866 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
34
35
<?php
// Database connection
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "lost_found_db";
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$email = isset($_GET['email']) ? $_GET['email'] : null;
if ($email) {
$sql = "SELECT id, Fname, Lname, email, dept, contactNo FROM users WHERE email = ?";
$stmt = $conn->prepare($sql);
$stmt->bind_param("s", $email);
$stmt->execute();
$result = $stmt->get_result();
if ($result->num_rows > 0) {
$row = $result->fetch_assoc();
echo json_encode($row);
} else {
echo json_encode(array("error" => "User not found"));
}
$stmt->close();
} else {
echo json_encode(array("error" => "No email parameter provided"));
}
$conn->close();
?>