Click to See Complete Forum and Search --> : Help on a password script


Shadow
06-10-2003, 04:01 PM
Hi,

I'm trying to make this script work using only the password field(instead of both a login and password) I only need one field for visitors to answer riddles in order to gain entrance to hidden pages. I do still need the success and failure pages however. Can someone help me?

Thanks!
Lisa


<form>
<p>ENTER USER NAME :
<input type="text" name="text2">
</p>
<p> ENTER PASSWORD :
<input type="password" name="text1">
<input type="button" value="Check In" name="Submit" onclick=javascript:validate(text2.value,"free",text1.value,"javascript") >
</p>

</form>
<script language = "javascript">

/*
Script by Anubhav Misra (anubhav_misra@hotmail.com)
Submitted to JavaScript Kit (http://javascriptkit.com)
For this and 400+ free scripts, visit http://javascriptkit.com
*/

function validate(text1,text2,text3,text4)
{
if (text1==text2 && text3==text4)
load('success.htm');
else
{
load('failure.htm');
}
}
function load(url)
{
location.href=url;
}
</script>

<p align="center"><font face="arial" size="-2">This free script provided by <a href="http://javascriptkit.com">JavaScript Kit</a></font></p>

pyro
06-10-2003, 05:00 PM
Javascript isn't the least bit secure, but for what you're doing, it doesn't sound like it really has to be. Give this a try:

<script type="text/javascript">
function checkPass(what) {
if (what.password.value == "test") {
top.location.href="yoursecretpage.htm";
}
}
</script>
</head>
<body>
<form>
<input type="password">
<input type="button" value="Submit" onclick="checkPass(this.form);">
</form>If you need it more secure, you will have to use server side programming.