simple login problem
Posted: Wed Mar 26, 2003 1:08 am
Hello,
I have a simple login problem.. What I want is when the user enters in there username and password they are taken to the index file of there own folder.so say there is user named "demo" and when "demo" logs in they are taken to the folder ~demo. Now im not sure how I should go about doing this.. all the code ive tried hasnt worked.. this is the last code I triend from someone on the fourm awile back.
I have a simple login problem.. What I want is when the user enters in there username and password they are taken to the index file of there own folder.so say there is user named "demo" and when "demo" logs in they are taken to the folder ~demo. Now im not sure how I should go about doing this.. all the code ive tried hasnt worked.. this is the last code I triend from someone on the fourm awile back.
Code: Select all
<?php
function validate_login ($user,$pass) {
if (empty($pass) || empty($user)) return false;
// get logindata from somewhere or check with something else like a db (and use md5 etc instead, such as if ($database_table_rowї'password'] === md5($user.$pass) ... )
$valid = array (
'f1' => 'test',
'f2' => 'test'
);
if ($validї$user] === $pass) return true;
else return false;
}
$user = $_SERVERї'PHP_AUTH_USER'];
if( validate_login($user, $_SERVERї'PHP_AUTH_PW']) ) { ?>
<HTML>
<HEAD>
<TITLE>Welcome to Members Area</TITLE>
</HEAD>
<BODY>
<h3>You have successfully logged in!</h3>
<p>Here are your options: </p>
<?php
$group = array(
'f1' => 'folder1',
'f2' => 'folder2'
);
include ('/path/to/file/'.$group($user));
// or whatever it is you want this user to get or link or se etc..
} // end auth-content
else { // begin no-auth content
header('WWW-Authenticate: Basic realm="Subdomain"');
header("HTTP/1.0 401 Unauthorized");
?><p>This page is PROTECTED by HTTP Authentication.<br>
DO NOT TRY TO ACCESS THIS SITE IF YOU ARE NOT AUTHERIZED!</p>
<?php
} // end no-auth-content
?>