PDA

View Full Version : WANTED: Javascript professionals!



bajiggity08
10-20-2005, 04:16 AM
Hello, everyone. I am currently editing a website of mine that is to serve two types of users. As such, I am writing to inquire on the html coding for making two usernames and two passwords for each of the two users, but opening a different window for each user upon submission.

Here is my code thus far as per Dynamic Drive (THANKS DD!!!):

<script>
//Encrypted Password script- By Rob Heslop
//Script featured on Dynamic Drive
//Visit http://www.dynamicdrive.com

function submitentry(){
password = document.password1.password2.value.toLowerCase()
username = document.password1.username2.value.toLowerCase()
passcode = 1
usercode = 1
for(i = 0; i < password.length; i++) {
passcode *= password.charCodeAt(i);
}
for(x = 0; x < username.length; x++) {
usercode *= username.charCodeAt(x);
}
//CHANGE THE NUMBERS BELOW TO REFLECT YOUR USERNAME/PASSWORD
if(usercode==########&&passcode==########)
//CHANGE THE NUMBERS ABOVE TO REFLECT YOUR USERNAME/PASSWORD
{
window.open("blank.htm","","fullscreen,scrollbars");top.window.close()}
else{
alert("Invalid Password/Username Combination")}
}
</script>
<font size="1" face="verdana"><div align="center">
<br>
<br>
<form name="password1">
<strong>Enter Username: </strong><input type="text" name="username2" size="10"> <strong>Enter Password: </strong><input type="password" name="password2" size="10"> <input type="button" value="Submit" onClick="submitentry()">
</form>


As observed, I can only let one user in at this time. I am in dire need of some javascript aid. So please please please reply ASAP.

Thanks everyone. Take care!!!

maartenvdj
01-16-2006, 09:58 PM
I had the same problem ... you have to change


if(usercode==########&&passcode==########)

to


if((usercode==########&&passcode==########) || (usercode==########&&passcode==########))

and it workes for me

Twey
01-16-2006, 10:34 PM
Note that
window.open("blank.htm"is insecure: it's the inclusion of the password in the filename that makes this script secure(-ish), and would also allow your two users to be redirected to different pages using maartenvdj's code.