-
Notifications
You must be signed in to change notification settings - Fork 1
/
identity_process.php
62 lines (55 loc) · 1.75 KB
/
identity_process.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
function sanitize_input($data) {
return htmlspecialchars(stripslashes(trim($data)));
}
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$idnum = sanitize_input($_POST['idnum']);
$found = false;
if (($handle = fopen("identities.csv", "r")) !== FALSE) {
fgetcsv($handle, 1000, ",");
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
if ($data[0] == $idnum) {
$found = true;
$firstName = $data[1];
$lastName = $data[2];
$address = $data[3];
$picture = $data[4];
break;
}
}
fclose($handle);
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Identity Result - pcpuppet.tech</title>
<link rel="stylesheet" href="css/styles.css">
</head>
<body>
<?php include 'header.html'; ?>
<div class="container">
<?php if (isset($found) && $found): ?>
<h2>User Details</h2>
<p><strong>First Name:</strong> <?php echo $firstName; ?></p>
<p><strong>Last Name:</strong> <?php echo $lastName; ?></p>
<p><strong>Address:</strong> <?php echo $address; ?></p>
<?php if (!empty($picture)): ?>
<img src="<?php echo $picture; ?>" alt="User Picture">
<?php else: ?>
<p>No picture available.</p>
<?php endif; ?>
<?php else: ?>
<h2>User Not Found</h2>
<p>No user found with ID number: <?php echo $idnum; ?></p>
<?php endif; ?>
<a href="identity.php"><button>Search Again</button></a>
</div>
<?php include 'footer.html'; ?>
</body>
</html>