secure a page
Moderator: General Moderators
secure a page
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.
- superdezign
- DevNet Master
- Posts: 4135
- Joined: Sat Jan 20, 2007 11:06 pm
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
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