I am trying to login into admin panel but getting parse error.
Parse error: syntax error, unexpected '{', expecting '('
Actually i have used condition if user role is admin then it should open one page and if user role is equal to employee it should open that page.
But it is getting this error.If am trying like this then
<?php session_start();
include '../includes/db.php';
if(isset($_POST['submit_login'])){
if(!empty($_POST['user_name']) && !empty($_POST['password'])){
$get_user_name = mysqli_real_escape_string($conn,$_POST['user_name']);
$get_password = mysqli_real_escape_string($conn,$_POST['password']);
$sql = "SELECT * FROM users WHERE username = '$get_user_name' AND user_password = '$get_password' AND user_role='admin'";
if($result = mysqli_query($conn,$sql)){
while($rows = mysqli_fetch_assoc($result)){
if(mysqli_num_rows($result) == 1){
$_SESSION['user'] = $get_user_name;
$_SESSION['password'] = $get_password;
$_SESSION['user_role'] = $rows['user_role'];
header('Location:../admin/index.php');
}
elseif{
header('Location:../admin/employeeindex.php');
}
else {
header('Location:../index.php?login_error=wrong');
}
}
}
else {
header('Location: ../index.php?login_error=query_error');
}
} else {
header('Location:../index.php?login_error=empty');
}
}else {
}
?>