authentication
am 27.06.2007 02:01:18 von SuperSlueth
hello
Im running the latest version of apache on a linux Fedora7 PC
I have several subdirectories of the main webpage.
I want users as the get onto the homepage to have to login in.
depending on th login name used i want them to be redirected to a
sub directory with the same name as the login name automatically.
Any ideas on how to achieeve this
I have MySQL and PHP loaded
Many thanks
Re: authentication
am 27.06.2007 02:50:04 von shimmyshack
On Jun 27, 1:01 am, Super Slueth wrote:
> hello
>
> Im running the latest version of apache on a linux Fedora7 PC
>
> I have several subdirectories of the main webpage.
>
> I want users as the get onto the homepage to have to login in.
>
> depending on th login name used i want them to be redirected to a
> sub directory with the same name as the login name automatically.
>
> Any ideas on how to achieeve this
>
> I have MySQL and PHP loaded
>
> Many thanks
either use htaccess to control the folders, which will protect whole
folders full of files, and stop people just typing in the urls, so you
could have a form on the homepage with a user field, and each
protected folder has its own htaccess with basic auth for each user,
the value for the username sets the forms action to the right folder
for that user using javascript, the user will be prompted with a user/
pass box, but once they have typed it in, usually the user is remember
between sessions, it will be clumsy but then once the user has logged
on the folder is open, and they will not need to log in again if they
have set the remember me box, which will mean they will need to
bookmark their own folders anyway - and wont need "redirecting".
OR
implement some kind of php login system, google has loads of ready to
run login scripts, some better than others, but for what you want, you
need to create a table in mysql with the users ane their hashed
passwords. The login form on the homepage takes the username and a
password. Then when these are posted, the script checks the table to
see if the $_POST{'user'] and md5($_POST['password']) ireturns exactly
one row in the mysql table. If it does then take the value of the
username, and do something like
if( $numRows == 1 )
$arrayUserToFolderMapping = array(
'bob'=>'bobbys_folder',
'mike'=>'michaels_folder',
'jon'=>'jonnys_folder',
'admin'=>'my_folder'
);
header('http://server.com/'.
$arrayUserToFolderMapping[$_POST['user'].'/');
exit;
}
however then just controls the redirection, now each and every file
that is owned by the user must be password protected, so when the user
is successful at login on, you must regenerate the session, and send a
cookie so that the browser "has permission" to access the files in
the folder, each file then checks for the appropriate cookie
so the above script would be modified to include some session stuff.
session_start();
//get posted data, check it against mysql
if( $numRows == 1 )
$arrayUserToFolderMapping = array(
'bob'=>'bobbys_folder',
'mike'=>'michaels_folder',
'jon'=>'jonnys_folder',
'admin'=>'my_folder'
);
session_regenerate();
header('http://server.com/'.
$arrayUserToFolderMapping[$_POST['user'].'/');
exit;
this is only VERY simple, you are encouraged to use google to find a
fully featured ready to run MODERN login system with good reports, it
isnt something you can get right yourself without experience, unless
it really doesnt matter about security.
}