-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathphpcode.php~
More file actions
47 lines (40 loc) · 2.48 KB
/
Copy pathphpcode.php~
File metadata and controls
47 lines (40 loc) · 2.48 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
<?php
$servername = "localhost";
$username = "proj_user3";
$password = "user99";
$dbname = "proj_user";
$conn = new mysqli ($servername, $username, $password, $dbname);
if ($conn->connect_error)
{
die ("Connection failed: ".$conn->connect_error);
}
$sql3 = "SELECT * FROM logins ORDER BY timestamp DESC LIMIT 5";
if($result = $conn->query($sql3)){
if(mysqli_num_rows($result) > 0){
echo "<table class='table table-bordered table-striped'>";
echo "<thead>";
echo "<tr>";
echo "<th>Username</th>";
echo "<th>IP Address</th>";
echo "<th>Timestamp</th>";
echo "</tr>";
echo "</thead>";
echo "<tbody>";
while($row = mysqli_fetch_array($result)){
echo "<tr>";
echo "<td>" . $row['username'] . "</td>";
echo "<td>" . $row['ip_address'] . "</td>";
echo "<td>" . $row['timestamp'] . "</td>";
echo "</tr>";
}
echo "</tbody>";
echo "</table>";
mysqli_free_result($result);
} else{
echo "<p class='lead'><em>No records were found.</em></p>";
}
} else{
echo "ERROR: Unable to execute query. " . $conn->error();
}
$conn->close();
?>