Let me point out the source of your trouble -
After the execution of the first if-else block:
if($curr_status=='Deactive') {
$message = "Sorry $user_email, your account is temporarily deactivated by the admin.";
}else{
$_SESSION['id'] = $res_id;
header("location: indexEmp.php?logid=$res_id");
}
It proceeds to execute the second if-else block:
if($roles =='admin') {
header("location: admin/index.php?logid=$res_id");
}else{
$_SESSION['id'] = $res_id;
header("location: indexEmp.php?logid=$res_id");
}
What happens? It is this second block of code that cancels out whatever is done in the first block. So, the next question is where to place this second block of code? That is for you to find out.
++++++[Follow up]++++++
Since you insist, take a look at this:
if($curr_status=='Deactive') {
$message = "Sorry $user_email, your account is temporarily deactivated by the admin.";
} else {
if($roles =='admin') {
header("location: admin/index.php?logid=$res_id");
} else {
$_SESSION['id'] = $res_id;
header("location: indexEmp.php?logid=$res_id");
}
}
I also observe that you are using root account to access the mysql database, that is a No-No. You should create a separate user account with restricted right for the PHP code to access a database.
++++++[Follow up 2]++++++
Another way is this:
if($roles =='admin') {
header("location: admin/index.php?logid=$res_id");
} else {
if($curr_status=='Deactive') {
$message = "Sorry $user_email, your account is temporarily deactivated by the admin.";
} else {
$_SESSION['id'] = $res_id;
header("location: indexEmp.php?logid=$res_id");
}
}