Click to See Complete Forum and Search --> : registration form question


davey
11-05-2003, 06:22 PM
here is my login code

<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=="goku" && password=="squib23") { window.location="member.php"; done=1; }
if (username=="vegeta" && password=="dirtmud56") { window.location="member.php"; done=1; }
if (done==0) { alert("Invalid login!"); }
}
function disableRightClick(e)
{
var message = "Right click disabled";

if(!document.rightClickDisabled) // initialize
{
if(document.layers)
{
document.captureEvents(Event.MOUSEDOWN);
document.onmousedown = disableRightClick;
}
else document.oncontextmenu = disableRightClick;
return document.rightClickDisabled = true;
}
if(document.layers || (document.getElementById && !document.all))
{
if (e.which==2||e.which==3)
{
alert(message);
return false;
}
}
else
{
alert(message);
return false;
}
}
disableRightClick();

// End -->
</SCRIPT>


now how would i make a registration page that would insert

if (username=="what the user filled out for their name" && password=="what the user filled out for their password") { window.location="member.php"; done=1; }

into the login page without me havin to do anything

(btw i want my registration form to look like

<form name=register>
<table width=225 border=1 cellpadding=3>
<tr><td colspan=2><center>
<font size="+2" font color="#FF6600"><b>Register</b></font>
</center></td></tr>
<tr>
<td><font color="#FF6600">Character:</font></td>
<td><input type=text name=username></td></font></tr>
<tr>
<td><font color="#FF6600">Password:</font></td>
<td><input type=password name=password></td></font></tr>
<tr><td colspan=2 align=center><input type=button value="Register" onClick="Register()"></td></tr>
</table>
</form>

^--that any help at all would be greatly appreciated

Gollum
11-06-2003, 03:05 AM
My best advice is "Don't do it this way".

For one thing, what you are asking for is how to modify the script that gets downloaded to the login page (which can only really be done on the server anyway).

Secondly - Every time someone registers, this will add a new line of code to your login page. If just 1000 people register that's almost 100kb extra to download each time and it gets worse the more you add.

Lastly - and possibly most importantly if you really want to restrict access to your members area, having this script code in your login page makes all the user ids and passwords visible to anyone who decides to view the source.


Login pages, etc are best done using server side scripts like ASP and PHP, etc. You store the user names and password in some database so that other users can't see them