/    Sign up×
Community /Pin to ProfileBookmark

Three Tries – Password protect not working

Let me start off by saying, “Thank you” to all have contributed to this site.

I downloaded a script to password protect a site and allow the user 3 tries to get into the protected area called “Three Tries”

The problem I’m getting is that if the user types the password wrong 2 times, he/she is prompted a 3rd time (this is as it should be). However, if the user [B]CORRECTLY[/B] types the password on the 3rd try, it kicks him/her to the previous site visited without reason. There is no error, it doesn’t go to the next ‘specified’ page.

Am I doing something wrong here?

Thanks,
Kelson

to post a comment
JavaScript

8 Comments(s)

Copy linkTweet thisAlerts:
@CrazyMerlinDec 30.2005 — We would need to see your code first.

I sounds like the password is not being posted to your script.

But we need to see it.
Copy linkTweet thisAlerts:
@konithomimoDec 30.2005 — Most likely you are incrementing before you evaluate the password, thus you are not actually ever evaluating the password the 3rd time.
Copy linkTweet thisAlerts:
@thabo22authorDec 30.2005 — Here's the code.

<html>

<head>

<SCRIPT LANGUAGE="JavaScript">

<!-- Begin

var testV = 1;

var pass1 = prompt('Please Enter Your Password','');

while (testV < 3) {
if (!pass1) history.go(-1);
if (pass1 == "password") {alert('You Got it Right!'); location.href('home.html'); break;}
testV+=1;
var pass1 = prompt('Access Denied, Please Try Again.','Password');
}


if (pass1 != "password" & testV == 3) {alert('nope'); location.href('failure.php')}

// End -->

</SCRIPT>

</head>

<body>

</body>

</html>
Copy linkTweet thisAlerts:
@FromU2MEDec 30.2005 — I made the changes which are shown in red. It should work well now. ?

[CODE]<html>
<head>

<SCRIPT LANGUAGE="JavaScript">

<!-- Begin

var testV = 1;
var pass1 = prompt('Please Enter Your Password','');

while (testV <[COLOR=Red]=[/COLOR] 3) {
if (!pass1) history.go(-1);
if (pass1 == "password") { alert('You Got it Right!'); [COLOR=Red]location.href = 'home.html'[/COLOR]; break;}
testV+=1;
var pass1 = prompt('Access Denied, Please Try Again.','Password');
}

if (pass1 != "password" &[COLOR=Red]&[/COLOR] testV == 3) {alert('nope'); [COLOR=Red]location.href = 'failure.php';[/COLOR]}

// End -->
</SCRIPT>

</head>
<body>
</body>
</html>[/CODE]
Copy linkTweet thisAlerts:
@methodpgDec 30.2005 — I'm not too sure... but I think you might need to change...

if (pass1 != "password" & testV == 3) {alert('nope');

to

if (pass1 != "password" && testV == 3) {alert('nope');

as well.

(Two "&" symbols)
Copy linkTweet thisAlerts:
@the_treeDec 30.2005 — Isn't this essentially pointless as the password can easilly be read from the source file?
Copy linkTweet thisAlerts:
@FromU2MEDec 30.2005 — The password could be encrypted - since we might not see the entire code... ?

Didn't notice the missing ampersand till now ?
Copy linkTweet thisAlerts:
@thabo22authorJan 02.2006 — Thanks to all who responded. It works great.

Kelson ?
×

Success!

Help @thabo22 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.29,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...