-
Notifications
You must be signed in to change notification settings - Fork 0
/
view-found-record.php
58 lines (57 loc) · 2.13 KB
/
view-found-record.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
<?php
ob_start();
session_start();
if (!isset($_SESSION['user_level']) or ($_SESSION['user_level'] != 1)) {
header("Location: login.php");
exit();
}
include '../html5req.php';
ob_end_flush();
?>
<h2 class="text-center">Search Result</h2>
<?php
// This code retrieves particular records from the users table
require 'mysqli-connect.php'; // Connect to the database
echo "<p>" . "If no record is shown, this is because you had an incorrect or missing entry in the search form" . "<br>" . "Click the back button on the browser and try again" . "</p>";
$fname = $_POST['fname'];
$lname = $_POST['lname'];
$fname = mysqli_real_escape_string($dbcon, $fname);
$lname = mysqli_real_escape_string($dbcon, $lname);
/*The query retrieves all the James Smith in the database*/
$q = "SELECT lname, fname, email, DATE_FORMAT(registration_date, '%M %d, %Y') AS regdat, user_id
FROM admintable
WHERE lname='$lname'AND fname='$fname'
ORDER BY registration_date ASC ";
$result = @mysqli_query($dbcon, $q); // Run the query
if ($result) {
// If it ran, display the records
// Display the table headings
echo '<table>
<tr><td><b>Edit</b></td>
<td><b>Delete</b></td>
<td><b>Last Name</b></td>
<td><b>First Name</b></td>
<td><b>Email</b></td>
<td><b>Date Registered</b></td>
</tr>';
// Fetch and display the records
while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) {
echo '<tr>
<td><a href="edit-user.php?id=' . $row['user_id'] . '">Edit</a></td>
<td><a href="delete-user.php?id=' . $row['user_id'] . '">Delete</a></td>
<td>' . $row['lname'] . '</td>
<td>' . $row['fname'] . '</td>
<td>' . $row['email'] . '</td>
<td>' . $row['regdat'] . '</td>
</tr>';
}
echo '</table>'; // Close the table
mysqli_free_result($result); // Free up the resources
} else {
// If it did not run properly
// Message
echo '<p class="alert-box alert round">The current users could not be retrieved. We apologize for any inconvenience.</p>';
// Debugging message
echo '<p>' . mysqli_error($dbcon) . '<br><br>Query: ' . $q . '</p>';
} // End of if ($result). Now display the figure for total number of records/members
?>