 |
| Coding Forum Problems with your code? Discuss coding issues, including JavaScript, PHP & MySQL, HTML & CSS, Flash & ActionScript, and more. |
|
 |
05-29-2009, 04:00 PM
|
#1 (permalink)
|
|
Contributing Member
Join Date: 03-25-06
Location: Galax, Virginia, USA
Posts: 157
Latest Blog: None
|
Need html for Password Protected Page
Here's a great javascript for password protecting a page, but I need a better one. Can anyone help?
What I am using now is:
<script language="JavaScript">
<!--hide
var password;
var pass1="LetMeIn";
password=prompt('Enter your password to view page.',' ');
if (password==pass1)
{ location="http://www.Password-Protected-Page.html" }
else {
window.location="http://www.WrongAnswer.com";
}
// end hide--> </script>
It's not terribly secure, but all I want to do is keep out the lookyloos. The problem is that too many of the people I want to use this page have JavaScripts disabled on their browsers, and it's too hard telling each of them how to find and fix this on their respective browsers. I was wondering, is there a way to do something similar with a standard html form? If I can cut and paste some code like this, I would love that. If I have to create a database on my server, I'll just hire someone to build the security for this site. Feel free to PM me if you want to quote building the security feature.
|
|
|
05-29-2009, 04:13 PM
|
#2 (permalink)
|
|
Moderator
Join Date: 01-23-07
Location: Buenos Aires, Argentina
Posts: 1,250
|
You should not use HTML/Javascript for password protection.
Do you have console access to the server? you can set up a .htaccess file to do a very basic password protection without doing any DataBase work. Follow this guide and it could take you about 10 minutes.
If you need help to do it just ask.
Regards.
__________________
Hades,
Ancient god, King of the Nether World, and Guardian of the Dead.
...and on my free time I'm also a web developer, contact me if you need one!
|
|
|
05-29-2009, 06:21 PM
|
#3 (permalink)
|
|
Meeow!
Join Date: 04-13-07
Location: Romania
Posts: 3,235
Latest Blog: None
|
Hades is right here. Never, and I mean NEVER, use javascript to password protect a page.
You'd have no way to prevent a user from getting that password from your script. Even if encrypted, yes. Unless you develop your own encryption algorithm, but I doubt you want to go there 
__________________
...to be continued
|
|
|
05-29-2009, 10:14 PM
|
#4 (permalink)
|
|
Super Moderator
Join Date: 10-29-07
Location: British Columbia, Canada
Posts: 3,275
|
What if the user has scripting turned off? 
|
|
|
05-30-2009, 09:08 AM
|
#5 (permalink)
|
|
Contributing Member
Join Date: 04-21-08
Posts: 101
Latest Blog: None
|
Quote:
Originally Posted by Costin Trifan
Hades is right here. Never, and I mean NEVER, use javascript to password protect a page.
You'd have no way to prevent a user from getting that password from your script. Even if encrypted, yes. Unless you develop your own encryption algorithm, but I doubt you want to go there 
|
yep only if he thinks of making ajax login but this is completely different.
javascript password can break 90% of internet users
|
|
|
05-30-2009, 09:39 AM
|
#6 (permalink)
|
|
Meeow!
Join Date: 04-13-07
Location: Romania
Posts: 3,235
Latest Blog: None
|
An ajax login system would most of the time require some server-side backend so it wouldn't be only javascript anymore; just like you said, it would be completely different.
__________________
...to be continued
|
|
|
06-01-2009, 07:37 AM
|
#7 (permalink)
|
|
Contributing Member
Join Date: 03-25-06
Location: Galax, Virginia, USA
Posts: 157
Latest Blog: None
|
Thanks, Hades. I think that is what I was looking for.
The javascript that is there now is the equivalent of one of those little locks on a desk drawer. It says "stay out," but anyone with bad intentions could jerk it open if they really tried. We understood that when we put it in place. We would have been happy with the low level of security for the non-sensitive materials we had on the page, but the javascript is turned off on just too many browsers. Hades option looks much better going forward. Thanks again.
|
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Hybrid Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -7. The time now is 02:46 PM.
© Copyright 2008 V7 Inc Powered by vBulletin Copyright © 2000-2009 Jelsoft Enterprises Limited.
|
|
|