how to check privilege in "check"php code or page ??
I using explode and in_array
after the user log in and in "check" page the code must check privilege of user if he has "dataDisplay" privilege or not ..but the code in "check" page doesn't do that
what's my wrong in "check" page code
this is my Database:
+--------------------+-------------------------------+
| username | user_privilege |
|--------------------|-------------------------------|
| amal |7gz,agt_courses,newbill |
| | |
+----------------------------------------------------+
| | |
| ahmed |dataDisplay,previllige,newUsers|
+----------------------------------------------------+
first page "login" php:
<?php
ob_start();
session_start();
include '../connection/connect.php';
$username = $_POST['username'];
$password = $_POST['password'];
if($username && $password ){
$finduser = mysqli_query($link,"SELECT * FROM LOGIN WHERE username = '".$username."' AND password = '".$password ."'") or die("error");
if(mysqli_num_rows($finduser) !=0){
while($row = mysqli_fetch_array($finduser)){
$uname = $row['username'];
$pass= $row['password '];
$arr=explode(",",$row['user_privilege']);
}
}
{
$_SESSION['sessionname'] =$uname;
$_SESSION['sessionpass'] =$password ;
$_SESSION['sessionpre'] =explode(",",$row['user_previllige']);
header ("location:../agtSite/agt2.php");
}
}
ob_end_flush();
?>
second page "check" php:
<?php
session_start();
$_SESSION['sessionpre']='';
$haspermission =in_array("dataDisplay",$_SESSION['sessionpre']);
if( $haspermission )
{
header("location: agt2.php");
}
else{header("location: ../display/display.php");}
?>