Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

help please 1

Status
Not open for further replies.

ameslee

Programmer
Feb 12, 2006
34
AU
i need some help, i am new at this and wondering why my program isnt working can someone plz help me!

<html><head>
<title>Password Application</title>
<script type = "text/VBScript">
option explicit
function pass1()
dim intusername, intpassword, user
intusername = document.frmpass.txtusername.value
intpassword = document.frmpass.txtpassword.value
Select case user
Case 1
intusername="nemo" AND intpassword="Clown"
window.location.href = "Case 2
intusername="dory" AND intpassword="Blue"
window.location.href="Case 2
intusername="bruce" AND intpassword="Shark"
window.location.href="End select
location.href="bad.htm"
end function
</script>
<body>
<h3>Enter Username and Password</h3>
<form method="post" name="frmpass">
Username:<input type="text" name="txtusername" size="10"><br>
Password:<input type="text" name="txtpassword" size="10"> <br>
<input type="button" value="Login" name="btnSubmit" onClick="pass1()"> </form>
</body>
</html>

thanks!
 
What's the error? We can read your script, just don't like to do so without you properly described what the problem is.
 
ok sorry, the error being: if the correct password and username are entered it still goes to the bad.htm page

thanks
 
This revision leave so much to desire. But it shows the essential.
[tt]
<html><head>
<title>Password Application</title>
<script type = "text/VBScript">
option explicit
function pass1()
dim intusername, intpassword, user
intusername = document.frmpass.txtusername.value
intpassword = document.frmpass.txtpassword.value
Select case intusername & ";" & intpassword '";" not generic, anything quite unique will do
Case [blue]"nemo;Clown"[/blue]
window.location.href = "[blue]http://[/blue] Case [blue]"dory;Blue"[/blue]
window.location.href=" Case "bruce;Shark"
window.location.href=" [red]Case Else[/red]
window.location.href="bad.htm"
End select

end function
</script>
<body>
<h3>Enter Username and Password</h3>
<form method="post" name="frmpass">
Username:<input type="text" name="txtusername" size="10"><br>
Password:<input type="[blue]password[/blue]" name="txtpassword" size="10"> <br>
<input type="button" value="Login" name="btnSubmit" onClick="pass1()"> </form>
</body>
</html>
[/tt]
 
What is user ? is it a string ?
Probably user is 0

The Case 2 is checked twice ?







 
Further note:

Also close the head tag.
[tt]
</script>
[red]</head>[/red]
<body>
[/tt]
 
can i just ask what the ";" means

Thanks so much. it works!

 
just to add on one more thing to this, how would i make the user only have 3 attempts, after 3 attempts they go to the error page
 
>can i just ask what the ";" means
You want to select case conditional where the conditional involves two variables at the same time. You have to find a way to make them both involved. One simple way is to combine (concatinate) them. For visual clarity, you separate them by something which is not in conflict with the plausible string fragment to appear in the 2nd variable. Here ";" does not appear in any one of the targetted password. Hence, it is acceptable. Any other choice like "%%%%%%%%" would also do under the same principle, just does not look pleasant to my eyes, that's all. In the individual case(s), the same separator is then scripted into it and must be consistent with the select case conditional.
 
does anyone know how i would make the user only have 3 attempts, after 3 attempts they go to the error page
 
[1] Add a global variable and initial to zero.
[tt]
<script type = "text/VBScript">
option explicit
dim count
count=0
function pass1()
[/tt]
[2] Then increase it every time the function is called.
[tt]
function pass1()
count=count+1
[/tt]
[3] Change the case else
[tt]
case else
if count>=3 then window.location.href="bad.htm"
end select
[/tt]
But all these client-side functionalities are only good for casual, friendly and trusted environment, absolutely not for hostile environment.
 
ok i have done this, after 3 attempts it goes to the bad.htm page. I need to also go to the bad.htm page if the username or password are wrong also, at the moment if it is wrong it doesnt do anything

 
all looks like if someone puts in something other than what is in the Case statements then it will go to bad.htm.
not sure about case sensitive though
 
>at the moment if it is wrong it doesnt do anything
It has 2 chances to be wrong. Is it not what you want? Now you want every time it's wrong will go to bad? In that case, what is wrong with the original script?

 
oh ok i understand, i think its fine now dont worry

thanks alot anyway
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top