Wednesday 4 September 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

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...