Solved

Password protected HTML page

Posted on 1998-11-01
9
141 Views
Last Modified: 2010-04-09
I want to restrict some pages on my web-site to users with a login and a password (much like the way I need to punch in my login name and password to use my Expert-Exchange account). How can I do this? Which tools do I need? Can this be done by HTML only?
0
Comment
Question by:shlomoy
  • 3
  • 2
  • 2
  • +2
9 Comments
 
LVL 4

Expert Comment

by:rafistern
ID: 1839334
You can do this by restricting access to the page on the server.

However what you can do with HTML only is:

<form name="theForm">
<input type="password" name="pwd">
<input type="button" value="Enter" onclick="location.href='document.theForm.pwd.value'+'.html'">
</form>

The name of the page is the password. Only someone who knows the password can find the page. Alternatively use the password as the name of the folder.
0
 
LVL 8

Author Comment

by:shlomoy
ID: 1839335
thing is - viewing the source code of the page reveiles the password and all...
0
 
LVL 4

Expert Comment

by:rafistern
ID: 1839336
No it doesn't.

The page contains the above script only. The name of the page is not included in the page at all.
0
ScreenConnect 6.0 Free Trial

Want empowering updates? You're in the right place! Discover new features in ScreenConnect 6.0, based on partner feedback, to keep you business operating smoothly and optimally (the way it should be). Explore all of the extras and enhancements for yourself!

 
LVL 84

Expert Comment

by:ozo
ID: 1839337
No, it doesn't.  the source code doesn't show what you input in the fform.
On the other hand, knowing the password, you could go directly to the document, making the form superfluous.
0
 
LVL 4

Expert Comment

by:rafistern
ID: 1839338
OK here is something even smarter:
Have the form take you to a page that contains a meta-refresh / location.href= or even better a location.replace that will take you to your off-bounds page.

Thus the new page:

<head>
<script>
if(location.replace)
  location.replace("theRealPage.html);
else
  location.href=("theRealPage.html);
</script>
</head>

 The advantages now are:
1. you can change the name of this page whenever you like without upsetting links or anything else.
2. a casual passer-by cannot see the password by reading the URL.

The location.replace is the best but not supported by all browsers (javascript 1.1 supported by NS3+, IE4+).


0
 
LVL 1

Expert Comment

by:rajgn
ID: 1839339
shlomoy:

Do you want to use Javascript where when a link to password protected file is clicked, a small new window pops up asking for password/username. If only when they are correct, it'll load the new page in the main window. By the way, where are yoou storing user anme and  passwords(I mean are you using any database?)
0
 
LVL 1

Expert Comment

by:Jason_G
ID: 1839340
Hi shlomoy,
Here are various sites that detail how to password protect your pages.
http://www.wsabstract.com/script/cut34.htm
http://www.5k.com/support/password.html 
http://lonestar.texas.net/~krigoni/frames/passw.html 
http://ag.arizona.edu/ecat/web/password-protect.html 
http://www.oz.net/jbrady/thegenie/java/cgpwdexample1.html 
http://www.irn.pdx.edu/~kerlinb/spin/passprotect.html 

I hope this helps.

Enjoy, and happy programming!

Sincerely,
Jason

Jason Gorman (jason_gorman@scholars.com)
Learning Advisor, http://scholars.com 
Microsoft Authorized Technical Education Center
Novell Authorized Online Training Provider
0
 
LVL 8

Author Comment

by:shlomoy
ID: 1839341
Jason_G - Thanks for your help (big help) if you will address your comment as an answer - I'll grant you the points. :-)

The rest of you guys - 10x for the tips, but Jason_G here offered some sites with some variety of solutions and/or implementations.
0
 
LVL 1

Accepted Solution

by:
Jason_G earned 100 total points
ID: 1839342
Hi Shlomoy,
Thanks, I'm glad they helped you!<grin>

Sincerely,
Jason

Jason Gorman (jason_gorman@scholars.com)
Learning Advisor, http://scholars.com
Microsoft Authorized Technical Education Center
Novell Authorized Online Training Provider
0

Featured Post

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
insert text field data into html script 13 41
How would I do a website like this? 5 56
Html5 Index on a table 7 26
If condition on Html with Asp 11 17
This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
This article discusses four methods for overlaying images in a container on a web page
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question