Forum Moderators: open

Message Too Old, No Replies

Password Protecting a hyperlink with destination on a local drive...

         

robbiebaird

10:30 am on Jun 2, 2005 (gmt 0)

10+ Year Member



Hi Everyone,

I am having trouble trying to password protect a htm file on my local hard drive. I want to hyperlink from one htm page to another but the 2nd has to be password protected.

From "http://www.2createawebsite.com/enhance/password-protect.html" I got:

======================================================
<script language="javascript">
<!--//
/*This Script allows people to enter by using a form that asks for a
UserID and Password*/
function pasuser(form) {
if (form.id.value=="userID") {
if (form.pass.value=="password") {
location="page2.html"
} else {
alert("Invalid Password")
}
} else { alert("Invalid UserID")
}
}
//-->
</script>

<center>
<table bgcolor="white" cellpadding="12" border="1">
<tr><td colspan="2"><center><h1><i><b>Login
Area</b></i></h1></center></td></tr>
<tr><td><h1><i><b>UserID:</b></i></h1></td><td><form name="login"><input
name="id" type="text"></td></tr>
<tr><td><h1><i><b>Password:</b></i></h1></td><td><input name="pass"
type="password"></td></tr>
<tr><td><center><input type="button" value="Login"
onClick="pasuser(this.form)"></center></td><td><center><br><input
type="Reset"></form></td></tr></table></center>
======================================================

I Changed the location "page2.html" to the .htm location on our local Y drive but it doesnt seem to be working. The actual password bit is OK but it says "page unavaibale" as if it is not loading. However, when i chance this location to a web page everything is fine!

Hope someone can help!

Robbie

Dijkgraaf

6:13 am on Jun 3, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Make sure that you have the URL to the file correct, as by the sound of it, you are trying to point to a locally mapped drive, rather than an page on the same web site.

e.g.
location="file:///y:/directory/page2.html"

P.S. 1) Anyone viewing the source of password-protect.html would be able to see the userId and password, this is not a secure way of doing password checking.
2) Only people who are internal to your network AND have Y: drive mapped to the same location would be able to see the page, others would get the page not found error.

robbiebaird

7:43 am on Jun 3, 2005 (gmt 0)

10+ Year Member



What is a more secure way of doing it?

kaled

1:57 pm on Jun 3, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Password protection must be at the operating system level. Javascript is useless.

You might conider placing the file in a shared directory and placing a password on the directory. Something along those lines should be ok. Alternatively, encryption software might offer a solution.

Kaled.