Wednesday, September 4, 2019

mysql - PHP Check if user is Admin

Ok, it seems you are assigning the value instead of comparing it. That is the reason why you always log in as an administrator.


Just change $row["role"] = 1 by $row["role"] == 1. Furthermore, you should use the && operator instead of ||.


Finally, it seems you are learning programming for the first time, and these are typical mistakes that everyone who is programmer had at the beginning. I recommend you the book "PHP: A Beginner's Guide", by Vikram Vaswani, which is an excellent and easy guide for those who are learning to program in PHP.


Good luck.

No comments:

Post a Comment

hard drive - Leaving bad sectors in unformatted partition?

Laptop was acting really weird, and copy and seek times were really slow, so I decided to scan the hard drive surface. I have a couple hundr...