1.

Solve : Submitting on ENTER and hiding passwords in source code?

Answer»

I know this isn't the most secure login script, but I'd like to add one more step of security. Is there any way I can link the first part of the code to a public file instead of including the whole thing? Right now PEOPLE can just look at the source code to see my list of clients. The info isn't top secret, but I'd like one more layer of protection if possible.

Also, I want to know how to be able to submit the form with the press of the ENTER button. keycode13 is involved, but I have no clue of where to place it.

Any HELP with either of these would be great. The code is below. Thank you.


Code: [Select]<SCRIPT LANGUAGE='JavaScript'>

<!-- Begin
function Login(){
var done=0;
var username=document.login.username.value;
username=username.toLowerCase();
var password=document.login.password.value;
password=password.toLowerCase();



if (username=="user1" && password=="password1") { window.location="URL1"; done=1; }

if (username=="user2" && password=="password2") { window.location="URL2"; done=1; }

if (username=="user3" && password=="password3") { window.location="URL3"; done=1; }

if (username=="user4" && password=="password4") { window.location="URL4"; done=1; }


if (done==0) { alert("Invalid login!"); }
}
// End -->
</SCRIPT>

<center>
<form name=login>
<table width=225 border=1 cellpadding=3>
<tr><TD colspan=2><center><font size="+2"><b>Client Login</b></font></center></td></tr>
<tr><td>Username:</td><td><input type=text name=username></td></tr>
<tr><td>Password:</td><td><input type=password name=password></td></tr>
<tr><td colspan=2 align=center><input type=button value="click here to view your credit account" onClick="Login()"></td></tr>
</table>
</form>

Javascript alone cannot hide usernames and passwords. Have you considered/tried using PHP? QUOTE from: kpac on August 19, 2010, 12:32:35 PM

Javascript alone cannot hide usernames and passwords. Have you considered/tried using PHP?


How would I implement that? Is that just saving the file as a text, then uploading it onto the internet with a public link?No, saving it as text means it's open for anyone to view, just like JS. See here: http://w3schools.com/php/php_post.asp Quote from: kpac on August 19, 2010, 03:23:30 PM
No, saving it as text means it's open for anyone to view, just like JS. See here: http://w3schools.com/php/php_post.asp


Thanks for the link. Looks pretty tough, but I'll give it a go. Do you have any info on how to make my form above recognize the PRESSING of ENTER? (keycode13???)Specifying an "action=" attribute should to the trick.


Discussion

No Comment Found