Click to See Complete Forum and Search --> : directory via username?
imaxjenn
02-01-2003, 03:19 PM
I am working on a personal site for fun, and would like to create a 'behind the scenes' area. I want it to be able to, based on the user name, send them to a different directory. I don't even know where to start looking. Is there a way to set it so that depending on what user name they enter, they are sent to the correct directory that corresponds with the name?:confused:
jeanne
02-24-2003, 02:30 PM
If you know beforehand who you want to go where and they must use their own names in a variation they'd recognize, you could probably do it based on a javascript redirect after they log on . . . I'm new also, but I've been working on redirects based on speed of connection/css-capable/javascript-capable browsers to 2 versions of my site, so thinking from this point of 1) determine who it is (get a user-login type script from javascriptsource.com ) 2) if it's this or that person they'll go here or there . . .
Anyway, not too helpful perhaps... it's an interesting problem. Would they have to logon from the opening of the site, or from where?
Then you'd take the variable resulting from getting the user's name and log in and adjust it so what's supposed to happen if it's this or that user is window.location="familypics.htm" or whatever.......
I'm not up to more without gruelling efforts and wild tests myself, but I hope you get it (or perhaps someone more advanced comes up with an answer)
There are two ways I know of doing this, but both involve Javascript. I would suggest the second way, as it is more secure. The first way is this:
<HTML>
<head>
<SCRIPT LANGUAGE="JavaScript">
function Login(){
var done=0;
var username=document.login.username.value;
username=username.toLowerCase();
var password=document.login.password.value;
password=password.toLowerCase();
if (username=="page" && password=="one") { window.location="page1.html"; done=1; }
if (username=="page" && password=="two") { window.location="directory1/page2.html"; done=1; }
if (username=="third" && password=="page") { window.location="page3.html"; done=1; }
if (done==0) { alert("Invalid login!"); }
}
</SCRIPT>
<BODY>
<CENTER>
Please Enter Your Username and password
<form name="form1">
Username: <input type="text" size="30" name="username">
<BR><BR>
Password: <input type="password" size="30" name="password">
<BR><BR>
<input type="button" value="Login" onClick="login()">
</CENTER>
</BODY>
</HTML>
where you can change the usernames and passwords and pages each gets taken to. Unofrtunately anyone who clicks view source will see what the usernames and passwords are.
The second way is this:
<HTML>
<HEAD>
<TITLE> Password Script </TITLE>
<script>
function login()
{
var password;
var username;
username=this.document.form1.username.value
password=this.document.form1.password.value
location.href=username + "/" + password + ".html"
}
</script>
</HEAD>
<BODY>
<CENTER>
Please Enter Your Username and password
<form name="form1">
Username: <input type="text" size="30" name="username">
<BR><BR>
Password: <input type="password" size="30" name="password">
<BR><BR>
<input type="button" value="Login" onClick="login()">
</CENTER>
</BODY>
</HTML>
where the username you type in is the directory that the page they will go to is in and the password is the name of the page.
So say this password page is in C:\ and you have a directory in it called STUFF and a webpage in stuff called PAGE1.HTML
then your username would be stuff and your password page1.
Hope this helps,
IxxI
jeanne
02-25-2003, 10:11 AM
very interesting . . . a little sneaky . . . Ha!