multi user/page login html |
multi user/page login html |
cmperry |
May 19 2010, 05:19 PM
Post
#1
|
Group: Members Posts: 2 Joined: 19-May 10 Member No.: 11,901 |
I am helping a friend build a website and she needs for her clients to be able to log in and see what work they have already done, security isn't really that big of a deal, I have found a code that is working for a single user to a single page and was wondering if someone could help me edit it for use with multi users going to different pages, there will be less than 50 seperate users and pages. any help is greatly appreciated!!!!
<form> <p>USER NAME : <input type="text" name="text2"> </p> <p>PASSWORD : <input type="password" name="text1"> <input type="button" value="Check In" name="Submit" onclick=java script:validate(text2.value,"a610",text1.value,"a610") > </p> </form> <script language = "javascript"> function validate(text1,text2,text3,text4) { if (text1==text2 && text3==text4) load('http://www.watcomechanical.net/applebees610.html'); else { load('failure.htm'); } } function load(url) { location.href=url; } </script> |
Christian J |
May 19 2010, 06:15 PM
Post
#2
|
. Group: WDG Moderators Posts: 9,653 Joined: 10-August 06 Member No.: 7 |
Assuming each client needs his own unique page and password, you can make a script that simply redirects to pages with the same name as the one entered in the form field. For example, if the client is called "foo" he'll go to "foo.html".
A server-side script (say PHP) is more robust than client-side javascript, though. |
cmperry |
May 19 2010, 06:57 PM
Post
#3
|
Group: Members Posts: 2 Joined: 19-May 10 Member No.: 11,901 |
I have a very basic knowledge of html (i.e. page breaks, color changes, center....) I sort of understand what you are saying but am not sure how to accomplish it, what do I need to change in the code?
|
Christian J |
May 20 2010, 06:21 AM
Post
#4
|
. Group: WDG Moderators Posts: 9,653 Joined: 10-August 06 Member No.: 7 |
I was thinking of something like this:
CODE <script type="text/javascript"> function redirect() { location.href=document.getElementById('pw').value+'.html'; } </script> <p> Enter password: <input type="password" id="pw" value=""> <input type="button" value="Go" onclick="redirect();"> </p> <noscript><p>Javascript is required for using the login.</p></noscript> |
Christian J |
May 20 2010, 06:32 AM
Post
#5
|
. Group: WDG Moderators Posts: 9,653 Joined: 10-August 06 Member No.: 7 |
With PHP you might use something like:
CODE <?php if(isset($_POST['pw']) && $_POST['pw']!='') { $host = $_SERVER['HTTP_HOST']; $uri = rtrim(dirname($_SERVER['PHP_SELF']), '/\\'); $extra = $_POST['pw'].'.html'; header("Location: http://$host$uri/$extra"); exit; } ?> <!doctype html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>Login</title> </head> <body> <form action="" method="post"> Enter password: <input type="password" name="pw" value=""> <input type="submit" value="Go"> </form> </body> </html> A disadvantage with both scripts is that incorrect passwords just cause a 404 (file not found) response, without explicitly saying that the PW was wrong. For more secure password protection, see http://htmlhelp.com/faq/html/publish.html#password |
geoffmerritt |
May 31 2010, 09:25 AM
Post
#6
|
Member Group: Members Posts: 66 Joined: 23-December 08 From: Adelaide Member No.: 7,394 |
@Christian J
I assume both your examples need the file name to be the same as the password eg, for client01.html the password is "client01". what the code is doing is completing the url, with the password. with a little jiggling you could do /client01/index.html |
Christian J |
Jun 2 2010, 12:33 PM
Post
#7
|
. Group: WDG Moderators Posts: 9,653 Joined: 10-August 06 Member No.: 7 |
@Christian J I assume both your examples need the file name to be the same as the password eg, for client01.html the password is "client01". what the code is doing is completing the url, with the password. That's correct. QUOTE with a little jiggling you could do /client01/index.html You mean, redirect to a directory instead of an HTML document? That may indeed be a more practical idea if each client page has many other associated files (images etc). |
Lo-Fi Version | Time is now: 19th April 2024 - 01:37 PM |