The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> multi user/page login html
cmperry
post 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>
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post May 19 2010, 06:15 PM
Post #2


.
********

Group: WDG Moderators
Posts: 8,246
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.

User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
cmperry
post 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?
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post May 20 2010, 06:21 AM
Post #4


.
********

Group: WDG Moderators
Posts: 8,246
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>

User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post May 20 2010, 06:32 AM
Post #5


.
********

Group: WDG Moderators
Posts: 8,246
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
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
geoffmerritt
post 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



User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Jun 2 2010, 12:33 PM
Post #7


.
********

Group: WDG Moderators
Posts: 8,246
Joined: 10-August 06
Member No.: 7



QUOTE(geoffmerritt @ May 31 2010, 04:25 PM) *

@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).
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 17th November 2019 - 04:50 AM