Hi everyone,
I need help on password protected directories on a server?
If I created a password protected directory and added users with their own passwords, is there any way that I can see who logged in and submitted data on the forms within the directory.
OR
How can I create a username and password form for all the pages within a directory so that each user must login before making use of the forms or pages. I do not want anybody to be able to access the forms only registered users.
Thank you all
Getting a password
Moderator: General Moderators
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
You can write PHP scripts that require log ins similar to the password protected directory stuff.
header() may be of interest along with http://php.net/features.http-auth
header() may be of interest along with http://php.net/features.http-auth
- dibyendrah
- Forum Contributor
- Posts: 491
- Joined: Wed Oct 19, 2005 5:14 am
- Location: Nepal
- Contact:
- dibyendrah
- Forum Contributor
- Posts: 491
- Joined: Wed Oct 19, 2005 5:14 am
- Location: Nepal
- Contact:
Taken from users note just for a sample.
Code: Select all
<?php
function auth_user() {
$realm = mt_rand( 1, 1000000000 );
header('WWW-Authenticate: Basic realm="Realm ID='.$realm.']"');
header('HTTP/1.0 401 Unauthorized');
die("Unauthorized access forbidden!");
}
if (!isset($_SERVER['PHP_AUTH_USER'])) {
auth_user();
} else if (!isset($_SERVER['PHP_AUTH_USER'])) {
auth_user();
} else if ($_SERVER['PHP_AUTH_USER'] != $auser || $_SERVER['PHP_AUTH_PW'] != $apass) {
auth_user();
} else if (isset($_GET['action']) && $_GET['action'] == "logout") {
auth_user();
}
....
?>