Page 1 of 1
secure a page
Posted: Tue Oct 16, 2007 4:42 pm
by Daron
How in PHP do you create a page that when you try to open it, it requires a username and password? I feel like this should be simple, but I just can't figure it out.
Posted: Tue Oct 16, 2007 5:14 pm
by superdezign
A form, some way of validating that the username and password are correct, and a session to determine if they are logged in.
Posted: Tue Oct 16, 2007 5:34 pm
by shannah
As with anything in development there are many ways to accomplish a task.
In addition to PHP form method, you could use Apache .htaccess files for authentication.
http://www.apacheweek.com/features/userauth
This explains how to protect a whole directory.
You can wrap these directives in a Filesmatch directive to only protect a particular file:
http://httpd.apache.org/docs/1.3/mod/co ... filesmatch
Alternatively you can do HTTP authentication (using HTTP headers) directly in PHP:
http://ca.php.net/features.http-auth
Hope this helps a little.
-Steve