PDA

View Full Version : How 2 Make A Password Enabled Area Using Javascript!



iRoss
14-02-2005, 02:31 PM
Hey,

Protecting private pages with passwords:

Javscript offers a variety of methods by which to password-protect your webpage(s). And some of the methods are very hack proof. However look else where if you are looking for maximum security!

This script is just an example of how javascript can be used to achieve password protection. This is the first part of the script:

<SCRIPT>
<!--

var wrong="if the password the person has enterd is incorrect put the page link 2 where they will be re-directed to here!"
var password="Type The Password You Wish In Here";
var name = prompt ("put what u want the text in the dialog box 2 say in here","the password u enterd here from earlier");
if (name == password) { (confirm("welcome!"))}
else {location.href=wrong}

//-->
</SCRIPT>

--------------------------------------------------------------------------

Here is a working version of it...

<SCRIPT>
<!--

var wrong="sorry.html";
var password="crazyfool";
var name = prompt ("enter the password","crazyfool");
if (name == password) {(confirm("welcome!"))}
else {location.href=wrong}

//-->
</SCRIPT>

--------------------------------------------------------------------------

1. Add the script and comment tags to the HEAD bit of your HTML document.
2. Type the javascript, changing the password to your own password.
3. Test the script in your browser to see if it works.

I hope that has helped someone... If noone :eusa_thin

Thanks :D

zainx
14-02-2005, 02:46 PM
it is a good idea but javascript wudnt be the best thing to use as if you right click and view source u can see wot pass it is to get to the restircted page

iRoss
14-02-2005, 02:48 PM
I Was Gonna Menchan That, But Decided Against It :P :eusa_wall

Mentor
14-02-2005, 02:54 PM
java script is a VERY insecure way to password a page, becuse the password is in the sorse.
You realy need php or cgi to make a viable password script.

There are ways where the pw isnt in the script, but the pw and user name if one is wanted appear in the page url meaning other pople could read it off.

iRoss
14-02-2005, 03:00 PM
well, it could be used for n00bs :P lol gimmie some rep go on :P lol i took alllllll that time and effort :P :eusa_wall

T0X!C-uk
14-02-2005, 03:05 PM
Very unsecure way to make passworded areas the best thing to do is use php or htaccess is also good.

Javascript passwords are best used in javascipt areas such as java games e.g. runescape etc as the source cannt be viewed and also a database is used

iRoss
14-02-2005, 03:06 PM
it is actually, if u go to any microsoft site, u cannot view the source, so if u had the code for that, noone would have 2 view the source 2 see it :D :eusa_clap omg all i wanted was a little rep just 2 show someone thinks that i made the effort but no, someone bad reps me for asking >:(

Mentor
14-02-2005, 07:36 PM
? The microsoft websites sorese is all there, They just write it in a starte line to make it hard for people to read?

splintercell!
14-02-2005, 08:11 PM
One javascript on I found meant you couldnt get to the source before entering the right pass..

Mentor
14-02-2005, 08:22 PM
One javascript on I found meant you couldnt get to the source before entering the right pass..
Yea but if u disbale javascript, wich i could do with the devolpsers tool bar on fire fox, o could go in and get the pass from the script easy as pie (mmm pie)

So with javascripst thers no real way of doing it. Athogh there are places that host free scripst you can sign up for, many including passoword protection, form handlers etc.
Before i had a php enbaled host i used http://scripthost.com/

-JT-
14-02-2005, 10:49 PM
This is where buying a host comes into use, afterall you get a htacsees password if you pay, lol (cheap skates :P)

zainx
14-02-2005, 10:52 PM
my cpanel is the worsed i get a protect a directory and it worked for like a second and then stopped, i aint got cpanel 9 or w/e is i got some isp thing

Eric30
16-02-2005, 03:04 PM
Yea but if u disbale javascript, wich i could do with the devolpsers tool bar on fire fox, o could go in and get the pass from the script easy as pie (mmm pie)

So with javascripst thers no real way of doing it. Athogh there are places that host free scripst you can sign up for, many including passoword protection, form handlers etc.
Before i had a php enbaled host i used http://scripthost.com/


You can disable t on IE ver easy! Just open the secriy serrngs and change to high or low Cant remember :P)

Anyway, If you dont want to do a lot of PHP coding... Just use HTaccess.

Lookie here: http://www.habboxforum.com/showthread.php?t=21354

Want to hide these adverts? Register an account for free!