Click to See Complete Forum and Search --> : Password in JS


gowans007
10-11-2004, 02:35 PM
Guys Can I do this is JS if so can you offer me any guidance.

All I want to do is have one webpage with a text box in asking for a password if the password is correct then to display a link to another page which can be clicked.

Any ideas guys?

Jupac
10-11-2004, 02:37 PM
This is unsafe using JS

you should try useing a server-side lagunage

Warren86
10-11-2004, 03:14 PM
gowans007:
If it's a single password for all users, then the following should work for you. The case-sensitive password is SunnyDay.

<HTML>
<Head>
<Script Language=JavaScript>

var linkStr = "<a href='nextPage.html'> Next Page </a>"

function validate(passWord){

if (passWord == 'SunnyDay'){isLink.innerHTML = linkStr}
else {pWord.reset();pWord.passWord.focus()}
}

</Script>
</Head>
<Body>
<Form name='pWord'>
<input type=hidden value='SunnyDay'>
Password: <input name='passWord' size=10><br><br>
<input type=button value='Submit' onClick="validate(passWord.value)">
</Form>
<Div id='isLink'></Div>
</Body>
</HTML>

Jupac
10-11-2004, 03:45 PM
Less do this with php


<?php
$password = "thisisthepass";
$pass = $_POST["pass"];
if($pass != $password){
echo "The Password is wrong";
}
else
{
echo "Good password";
}
?>


<form method="post" action="<?php echo $PHP_SELF; ?>">
<input type="text" name="pass" />
<input type="submit" />
</form>


heres the demo (http://www.kidscript.com/pass_demo.php)

etard
10-12-2004, 02:08 PM
here is one I use. allows for username and password. they cannot look at the source code for either to bypass as you encrypt the user name and password and then add the encrypted results to the code - so it looks like gibberish. also, they cannot see the page it gets sent to as it is tied to the password and is not in the code.. easy to use. works perfeect. simple for simple baisc non crucial security.

http://www.dynamicdrive.com/dynamicindex9/password.htm

Jeff Mott
10-12-2004, 10:18 PM
JavaScript actually can be secure if done properly. Here is another thread with solutions and discussions.

http://www.webdeveloper.com/forum/showthread.php?threadid=45175

gowans007
10-14-2004, 07:22 PM
Thanks guys,

Loadsa help as always!

The only language I would be able to use for this is javascript I'll give your ideas a go.

It doesn't really have to majorly secure as its going on a secure network with limited internet settings.

All it needs to do is link to another page if password is correct.

thanks!!

Paul Jr
10-14-2004, 10:52 PM
One way of making it a bit more “secure” is to make the filename of the restricted page the password, or part of it, that way the person cannot just look which file you are directed to after inputting the correct password.