I need to password protect a php document. I've done it, but it doesn't work particularly well. The document does DB administration (view, add, edit and delete entries). Right now it consists of 2 pages. One is a simple HTML portal that asks for a password, and POSTS it to the "main" page (admin.php). Here's the part that deals with the password in admin.php:
Now, that works fine and dandy. Until someone needs to do anything. If you do a task (for this example, we'll say you deleted something) it redirects you to $PHP_SELF with various options POST'd or GET'd. Then when you return to the manager's default page it requires your password again.
Any suggestions? The most obvious one to me is to passivly post the password once it's been succesfully entered once, but is this neccesarily good? Ease and elegance are key here.
code:<HR>Code:<?php if (!$pass) { echo "You didn't enter a password, please go back and try again! \n</body> \n</html>"; die; } else { $db = @mysql_connect("localhost","bnc","$pass") or die("You've entered an invalid password, or the database is down. Go back and try again! \n</body> \n</html>"); }
Now, that works fine and dandy. Until someone needs to do anything. If you do a task (for this example, we'll say you deleted something) it redirects you to $PHP_SELF with various options POST'd or GET'd. Then when you return to the manager's default page it requires your password again.
Any suggestions? The most obvious one to me is to passivly post the password once it's been succesfully entered once, but is this neccesarily good? Ease and elegance are key here.