I am struggling with redirecting to a admin panel page in php. I have tried 2 different codes without success. I have no idea what I am doing, as I don't have a good solid understanding of the fundamentals of php. But I think I'm getting close, any help appreciated. Thankyou in advance.
user_level is the entry in the database , 2 is for members and 3 for admin. error logs posted at the bottom.
$username = $_SESSION['username'];
while($row = mysqli_fetch_object($conn))
{
$admin = $row->user_level;
}
if ($admin == 3) { header('Location: admin.php');
}
code 2
$username = $_SESSION['username'];
$query_level = mysqli_query("SELECT user_level FROM members WHERE username = '$username' ");
$run_level = mysqli_fetch_array($conn, $query_level);
$row = mysqli_fetch_assoc($run_level);
if ($row == 3) {
header('Location: admin.php');
}
[26-Jun-2016 09:03:09 Australia/Brisbane] PHP Warning: mysqli_fetch_object() expects parameter 1 to be mysqli_result, object given in /public_html/login/memberpage.php on line 46 [26-Jun-2016 09:03:09 Australia/Brisbane] PHP Notice: Undefined variable: admin in /public_html/login/memberpage.php on line 51
26-Jun-2016 09:05:06 Australia/Brisbane] PHP Warning: mysqli_query() expects at least 2 parameters, 1 given in /public_html/login/memberpage.php on line 46 [26-Jun-2016 09:05:06 Australia/Brisbane] PHP Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, null given in /public_html/login/memberpage.php on line 47 [26-Jun-2016 09:05:06 Australia/Brisbane] PHP Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, null given in /public_html/login/memberpage.php on line 48
Aucun commentaire:
Enregistrer un commentaire