Warm tip: This article is reproduced from stackoverflow.com, please click
html mysql php redirect

What is the best way to redirect users where there are admins and regular users?

发布于 2020-04-13 09:30:06

I have a CMS environment where there are administrator users and I need a way to redirect users who are either not administrators or do not own the document they're trying to edit. It looks something like this, but my administrators cannot access the page this way and Im unsure why:

$cannotpass=0;
if ($reportsusername != $usersusername) {
    $cannotpass++;
}

if ($usersadmin != $admin) {
    $cannotpass++;
}   

if ($cannotpass >= 1) {
    header("location:http://decibeldesignstudios.com/blackbirdsecurity/adminlanding");  
}
Questioner
Dustin
Viewed
47
technophyle 2020-02-03 04:33

Why do you need a counter?

You can simplify it as follows:

if ($reportsusername != $usersusername && $usersadmin != $admin) {
    header("location:http://decibeldesignstudios.com/blackbirdsecurity/adminlanding");  
}