I am trying to make a simple login system in javascript. The code should be for multiple users
e.g: user: love pass: cat, user2: mom pass2: love etc.
I need the code to redirect users to certain pages e.g. if username textbox has the text LOVE and pass is cat then user should be redirected to page1.html if username is MOM and pass is love then user should be redirected to page2.html
P.S. I know all security issues that occur when using javascript login but those are for a school project.
I tried:
<SCRIPT LANGUAGE="JavaScript">
function Getstats()
{
window.status=('Attempting to Login to user area.')
var AccId;
var iName;
AccId = document.iAccInput.iAccID.value
iName = document.iAccInput.iName.value
if (AccId == "" || iName == "")
{
alert('\nERROR\nYou must enter ALL Details,\nto View your statistics.\n');
window.status=('Missing data or Invalid. Check spelling and Ensure Names are in Correct Case.')
}
else
{
var location=(iName + ".html");
this.location.href = location;
window.status=(' Verifying: ' + iName +' Please wait........');
}
}
</SCRIPT>
<hr><FORM NAME="iAccInput">
<CENTER>
<TABLE BORDER="1px" bordercolor="#c0c0c0" cellpadding="5" cellspacing="0">
<TR>
<TD ALIGN="RIGHT">
<p><FONT SIZE="3" FACE="Arial"><B>User Name:</B></FONT>
</p></td>
<TD>
<INPUT TYPE="TEXT" NAME="iName" MAXLENGTH="15">
</td>
<TD>
</td>
</tr>
<tr>
<TD ALIGN="RIGHT">
<p><FONT SIZE="3" FACE="Arial"><B>Password:</B></FONT>
</p></TD>
<td>
<INPUT NAME="iAccID" MAXLENGTH="15" HEIGHT="50">
</TD>
<td align="center">
<INPUT TYPE="BUTTON" VALUE=" Login " onClick="Getstats()" HEIGHT="40" WIDTH="50"><BR><br>
<INPUT TYPE="RESET" VALUE=" Reset " onClick="window.status=('RESET: Please enter your USERNAME and ACCOUNT ID.')" WIDTH="50">
</td>
</TR>
</TABLE>
But this use another kind of algorithm. If anyone know, please let me know. thanks you!