PDA

View Full Version : help needed javascript encripted password form



john945
10-28-2011, 10:57 AM
hi im using a encrypted password script, im new to javascript, ive set four users, it works fine and forwards correctly, however on all but one password teven though the password works and forwards to a url the alert box appears, i cant work out why!.

also a simple one i want the submit button to be horizontally inline with the input box.

The passwords are:

john

james

tim

phil

The script ive used is below, many thanks.


<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()

passcode = 1
for(i = 0; i < password.length; i++) {
passcode *= password.charCodeAt(i);
}

//CHANGE THE NUMBERS BELOW TO REFLECT YOUR USERNAME/PASSWORD
if(passcode==134603040)
//CHANGE THE NUMBERS ABOVE TO REFLECT YOUR USERNAME/PASSWORD
{
window.location="http://www.google.com"}

//CHANGE THE NUMBERS BELOW TO REFLECT YOUR USERNAME/PASSWORD
if(passcode==13017371870)
//CHANGE THE NUMBERS ABOVE TO REFLECT YOUR USERNAME/PASSWORD
{
window.location="http://www.yahoo.com"}

//CHANGE THE NUMBERS BELOW TO REFLECT YOUR USERNAME/PASSWORD
if(passcode==132088320)
//CHANGE THE NUMBERS ABOVE TO REFLECT YOUR USERNAME/PASSWORD
{
window.location="http://www.ebay.com"}

//CHANGE THE NUMBERS BELOW TO REFLECT YOUR USERNAME/PASSWORD
if(passcode==1327620)
//CHANGE THE NUMBERS ABOVE TO REFLECT YOUR USERNAME/PASSWORD
{
window.location="http://www.hotmail.com"}

else{
alert("EITHER: Passcode incorrect.")}
}
</script>

<form name="password1">

<input type="password" name="password2" size="15">

<input type="button" value="Submit" onClick="submitentry()">
</form>

jscheuer1
10-28-2011, 04:01 PM
First off this provides like Zero security. Anyone can look at the source code and see the destinations and navigate directly to them.

But to answer your question, you need to make all but the first if else if:


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


function submitentry(){
password = document.password1.password2.value.toLowerCase()

passcode = 1
for(i = 0; i < password.length; i++) {
passcode *= password.charCodeAt(i);
}

//CHANGE THE NUMBERS BELOW TO REFLECT YOUR USERNAME/PASSWORD
if(passcode==134603040)
//CHANGE THE NUMBERS ABOVE TO REFLECT YOUR USERNAME/PASSWORD
{
window.location="http://www.google.com"}

//CHANGE THE NUMBERS BELOW TO REFLECT YOUR USERNAME/PASSWORD
else if(passcode==13017371870)
//CHANGE THE NUMBERS ABOVE TO REFLECT YOUR USERNAME/PASSWORD
{
window.location="http://www.yahoo.com"}

//CHANGE THE NUMBERS BELOW TO REFLECT YOUR USERNAME/PASSWORD
else if(passcode==132088320)
//CHANGE THE NUMBERS ABOVE TO REFLECT YOUR USERNAME/PASSWORD
{
window.location="http://www.ebay.com"}

//CHANGE THE NUMBERS BELOW TO REFLECT YOUR USERNAME/PASSWORD
else if(passcode==1327620)
//CHANGE THE NUMBERS ABOVE TO REFLECT YOUR USERNAME/PASSWORD
{
window.location="http://www.hotmail.com"}

else{
alert("EITHER: Passcode incorrect.")}
}