-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlist.php
59 lines (53 loc) · 1.34 KB
/
list.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
<?php
//including the controller to reduce rewrite of few codes
require_once('functions.php');
//start session
session_start();
/*if session is not set go to login page else create new controller object,
query the database and store the resuts in variable records*/
if(!isset($_SESSION['pw'])){
header('location:login.php');}
$dsn=new sqdbc();
$query = "SELECT * from users";
$records=$dsn::dbFetchAll($query);
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>List</title>
<link rel="stylesheet" type="text/css" href="css/phpcha.css">
</head>
<body>
<div id="top">
<h1>PHP Challenge</h1>
<h4>For Admin Use Only</h4>
</div>
<p><a href="welcomepage.php">< BACK</a></p>
<table>
<thead>
<tr>
<td>Userid</td>
<td>Name</td>
<td>Option</td>
</tr>
</thead>
<tbody>
<?php foreach($records as $record): ?>
<tr>
<td><?php echo htmlspecialchars($record['userid']); ?></td>
<td><?php echo htmlspecialchars($record['name']); ?></td>
<td>
<form action="delete.php" method="post">
<div>
<input type="hidden" name="name" value="<?php echo htmlspecialchars($record['name']); ?>">
<input type="submit" name="delete" value="Delete">
</div>
</form>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</body>
</html>