<!doctype HTML>

<html lang="en">

<?php
include('navbar.php');
session_start();
include('DBConn.php');
?>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Pastimes - Admin Verify</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class= "verifyStyle">
<?php
// Handle "Accept" or "Decline" action
if (isset($_POST['accept'])) {
$userId = $_POST['userId'];

// Update user to be verified (set verified = 1)
$updateQuery = "UPDATE tblUser SET verified = 1 WHERE user_id = ?";
$stmt = mysqli_prepare($conn, $updateQuery);
mysqli_stmt_bind_param($stmt, 'i', $userId);

if (mysqli_stmt_execute($stmt)) {
echo "<script>alert('User verified successfully!');</script>";
} else {
echo "<script>alert('Error verifying user: " . mysqli_error($conn) . "');</script>";
}
mysqli_stmt_close($stmt);
}

if (isset($_POST['delete'])) {
$userId = $_POST['userId'];

// Remove user from the table
$deleteQuery = "DELETE FROM tblUser WHERE user_id = ?";
$stmt = mysqli_prepare($conn, $deleteQuery);
mysqli_stmt_bind_param($stmt, 'i', $userId);

if (mysqli_stmt_execute($stmt)) {
echo "<script>alert('User deleted successfully!');</script>";
} else {
echo "<script>alert('Error deleting user: " . mysqli_error($conn) . "');</script>";
}
mysqli_stmt_close($stmt);
}

if (isset($_POST['revoke'])) {
$userId = $_POST['userId'];

// Update user to be unverified (set verified = 0)
$revokeQuery = "UPDATE tblUser SET verified = 0 WHERE user_id = ?";
$stmt = mysqli_prepare($conn, $revokeQuery);
mysqli_stmt_bind_param($stmt, 'i', $userId);

if (mysqli_stmt_execute($stmt)) {
echo "<script>alert('User revoked successfully!');</script>";

} else {
echo "<script>alert('Error revoking user: " . mysqli_error($conn) . "');</script>";
}
mysqli_stmt_close($stmt);
}

// Fetch all users
$query = "SELECT * FROM tblUser";
$result = mysqli_query($conn, $query);

if ($result) {
while ($userRow = mysqli_fetch_assoc($result)) {
echo '<div>';
echo 'First Name: ' . $userRow['first_name'] . ' - Last Name: ' . $userRow['last_name'] . ' - Username: ' . $userRow['username'] . ' - Address: ' . $userRow['address'] . ' - ' . ($userRow['verified'] ? 'Verified' : 'Not Verified');

// Create a form with action buttons
echo '<form method="POST" style="display:inline-block;">';
echo '<input type="hidden" name="userId" value="' . $userRow['user_id'] . '">';
if (!$userRow['verified']) {
echo '<button type="submit" name="accept">Accept</button>';
echo '<button type="submit" name="delete">Delete</button>';
} else {
echo '<button type="submit" name="revoke">Revoke</button>';
}
echo '</form>';

echo '</div><br>';
}
} else {
echo "Error in query: " . mysqli_error($conn);
}

// Close the connection
mysqli_close($conn);
?>
</div>

</body>
</html>

add css styling to the verifyStyle to make the format more clear

1 answer

To enhance the styling of the verifyStyle class in your HTML page, you can add CSS rules that improve the overall presentation and readability. Here’s an example of how you might style the verifyStyle class, including button styling for the forms.

  1. In your style.css file, you can add the following CSS rules:
.verifyStyle {
    max-width: 800px; /* Limit the width for better readability */
    margin: 20px auto; /* Center it on the page */
    padding: 20px; /* Add some padding */
    border: 1px solid #ccc; /* Add a border */
    border-radius: 10px; /* Rounded corners */
    background-color: #f9f9f9; /* Light background color */
    box-shadow: 2px 2px 10px rgba(0, 0, 0, 0.1); /* Subtle shadow */
    font-family: Arial, sans-serif; /* Use a clean font */
}

.verifyStyle div {
    padding: 10px; /* Add spacing between user entries */
    border-bottom: 1px solid #ddd; /* Separate individual user entries */
}

.verifyStyle div:last-child {
    border-bottom: none; /* Remove border from the last item */
}

.verifyStyle button {
    margin-left: 10px; /* Space between buttons */
    padding: 10px 15px; /* Button size */
    border: none; /* Remove default border */
    border-radius: 5px; /* Rounded corners for buttons */
    cursor: pointer; /* Help cursor indicates clickable */
}

.verifyStyle button:hover {
    opacity: 0.8; /* Change opacity on hover */
}

.verifyStyle button:focus {
    outline: none; /* Remove outline on focus */
}

.verifyStyle .verified {
    color: green; /* Color for verified users */
}

.verifyStyle .not-verified {
    color: red; /* Color for not verified users */
}
  1. Make sure to apply the classes in your PHP echo statements accordingly. Here’s a plus option for your dynamic display showing verification status:
echo 'First Name: ' . $userRow['first_name'] . ' - Last Name: ' . $userRow['last_name'] . ' - Username: ' . $userRow['username'] . ' - Address: ' . $userRow['address'] . ' - <span class="' . ($userRow['verified'] ? 'verified' : 'not-verified') . '">' . ($userRow['verified'] ? 'Verified' : 'Not Verified') . '</span>';

This will give a clear visual distinction between verified and non-verified users by using colors.

Putting it all together, you will achieve a clearer and more user-friendly display for your admin verification page, making it easier for admins to manage user status effectively.