Using "if" statement to determine if a user is an admin drawing from mySQL database.
Every place I have looked says that the mysql_fetch_array is deprecated but does not give any alternatives.
$sql = "SELECT * FROM user WHERE user='$username' &&
password='$password' ";
$result = $conn->query($sql);
if($row = mysql_fetch_array($result))
{
$_SESSION['id'] = "".$row['id']."";
$_SESSION['username'] = "".$row['user'].""; // Username
$_SESSION['admin'] = "".$row['admin'].""; // Admin
$_SESSION['seclvl'] = 1; // Security Level
}
The code should connect to the database, using a login form to determine if the SESSION user is a site admin and allow them access to certain pages, if they are not an admin it only shows basic pages. The login does not return the expected results.
Aucun commentaire:
Enregistrer un commentaire