Can you help me I have a problem with my code? This code below was the login process page and I want to redirect it to specific page either admin homepage or user homepage. When I run it those account assigned as User it will redirect to Admin Page. I have no problem those account assigned as Admin because it automatically redirect to Admin Page.
session_start();
$message = "";
if(count($_POST) > 0){
$conn = mysql_connect("localhost", "root", "");
mysql_select_db("etransmittal", $conn);
$result = mysql_query("SELECT * FROM tbl_userlist WHERE username = '" . $_POST["userid"] . "' AND user_password = '" . $_POST["userpassword"] . "'");
$row = mysql_fetch_array($result);
if(is_array($row)){
$_SESSION['userid'] = $row['userid'];
$_SESSION['username'] = $row['username'];
$_SESSION['userrole'] = $row['userrole_id'];
$_SESSION['firstname'] = $row['fname'];
$_SESSION['middlename'] = $row['mname'];
$_SESSION['lastname'] = $row['lname'];
$_SESSION['nbu'] = $row['nbu'];
$_SESSION['department'] = $row['department'];
$_SESSION['branch'] = $row['branch'];
}
else{
$message = "Invalid username or password";
}
}
/*if(isset($_SESSION['userid'])){
header("location: admin_homepage.php");
}*/
if(isset($_SESSION['userrole']) == '1'){
header("location: admin_homepage.php");
}
else if(isset($_SESSION['userrole']) == '2'){
header("location: user_homepage.php");
}