Ex.php new checkadminstatus

It looks like you're asking about a PHP script that checks the admin status of a user.

Here's a simple example of how you could implement this:

ex.php

<?php

// Define the admin status variable
$isAdmin = false;

// Check if the user is logged in
if (isset($_SESSION['username'])) {
    // Get the user's role from the database
    $userRole = getUserRoleFromDatabase($_SESSION['username']);

    // Check if the user is an admin
    if ($userRole == 'admin') {
        $isAdmin = true;
    }
}

// Output the admin status
echo $isAdmin? 'You are an admin' : 'You are not an admin';

// Function to get the user's role from the database
function getUserRoleFromDatabase($username) {
    // Connect to the database
    $db = mysqli_connect('localhost', 'username', 'password', 'database');

    // Query the database to get the user's role
    $query = "SELECT role FROM users WHERE username = '$username'";
    $result = mysqli_query($db, $query);

    // Get the user's role from the result
    $row = mysqli_fetch_assoc($result);
    $role = $row['role'];

    // Close the database connection
    mysqli_close($db);

    return $role;
}

?>

In this example, we first check if the user is logged in by checking if the $_SESSION['username'] variable is set. If the user is logged in, we get their role from the database using the getUserRoleFromDatabase function. We then check if the user's role is 'admin' and set the $isAdmin variable accordingly. Finally, we output the admin status using an if statement.

Note that this is a very basic example and you should consider implementing proper security measures, such as validating user input and using prepared statements to prevent SQL injection.