plasterx
11-19-2005, 03:32 AM
Hi all,as usual i've got tonnes of problems,so sorry because i'm really lousy at asp. my problem now is on the Login process... i wanna know how do i check if the login name actually exists in the database? and not some tom dick or harry can just login . I mean,users are actually required to register first (their information wil be stored in the db) before they can login.
I've got this on my Login.asp:
<script language="Javascript">
function chck( Frm ) {
if ( !Frm.loginname.value ) {
alert("Alert: Please enter your User Name.");
Frm.loginname.focus();
return false;
}
if ( !Frm.password.value) {
alert("Alert: Please enter your Password.");
Frm.password.focus();
return false;
}
return true;
}
</script>
</head>
<body>
<p>
<center>
<form name="Login" method="post" action="loginSuccess.asp" onSubmit="return chck( this );">
<table width="560">
<p><img src="images/dinologo.bmp" width="620" height="100">
<p>
<font size="+2">Administrator Login</font>
<p>
<p>
<tr>
<td>Login Name: </td>
<td width="466"><input type="text" name="loginname"></td>
</tr>
<p>
<tr>
<td>Password:</td>
<td><input type="password" name="password"></td>
</tr>
<p>
<tr>
<td><input type="Submit" value="Login"></td>
</tr>
</center>
</table>
</form>
and this on LoginSuccess.asp:
<%
Set Conn = Server.CreateObject("ADODB.Connection")
Set RS = Server.CreateObject("ADODB.RecordSet")
strConn = "DSN=FYP_Actual;DRIVER={SQL SERVER};UID=sa;PWD=;"
Conn.Open strConn
Dim strLoginName
strLoginName = Request.Form("LoginName")
Set Conn = Server.CreateObject("ADODB.Connection")
Set RS = Server.CreateObject("ADODB.RecordSet")
strConn = "DSN=FYP_Actual;DRIVER={SQL SERVER};UID=sa;PWD=;"
Conn.Open strConn
Dim SQL
SQL = "Select * from Login where LoginName = '" & Request.Form("loginName") &"' and password = '" &Request.Form("password")&"'"
Set RS = Conn.Execute(sql)
Response.Write(RS.recordCount)
Response.Write SQL
%>
I'm like stuck halfway after the SQL statement. I know i'm supposed to do like a recordCount to check if there are firstly any records in the db,and then whether the user name i keyed in exists... it's like an if else statement?????
HELP !!! Thanks again ..
I've got this on my Login.asp:
<script language="Javascript">
function chck( Frm ) {
if ( !Frm.loginname.value ) {
alert("Alert: Please enter your User Name.");
Frm.loginname.focus();
return false;
}
if ( !Frm.password.value) {
alert("Alert: Please enter your Password.");
Frm.password.focus();
return false;
}
return true;
}
</script>
</head>
<body>
<p>
<center>
<form name="Login" method="post" action="loginSuccess.asp" onSubmit="return chck( this );">
<table width="560">
<p><img src="images/dinologo.bmp" width="620" height="100">
<p>
<font size="+2">Administrator Login</font>
<p>
<p>
<tr>
<td>Login Name: </td>
<td width="466"><input type="text" name="loginname"></td>
</tr>
<p>
<tr>
<td>Password:</td>
<td><input type="password" name="password"></td>
</tr>
<p>
<tr>
<td><input type="Submit" value="Login"></td>
</tr>
</center>
</table>
</form>
and this on LoginSuccess.asp:
<%
Set Conn = Server.CreateObject("ADODB.Connection")
Set RS = Server.CreateObject("ADODB.RecordSet")
strConn = "DSN=FYP_Actual;DRIVER={SQL SERVER};UID=sa;PWD=;"
Conn.Open strConn
Dim strLoginName
strLoginName = Request.Form("LoginName")
Set Conn = Server.CreateObject("ADODB.Connection")
Set RS = Server.CreateObject("ADODB.RecordSet")
strConn = "DSN=FYP_Actual;DRIVER={SQL SERVER};UID=sa;PWD=;"
Conn.Open strConn
Dim SQL
SQL = "Select * from Login where LoginName = '" & Request.Form("loginName") &"' and password = '" &Request.Form("password")&"'"
Set RS = Conn.Execute(sql)
Response.Write(RS.recordCount)
Response.Write SQL
%>
I'm like stuck halfway after the SQL statement. I know i'm supposed to do like a recordCount to check if there are firstly any records in the db,and then whether the user name i keyed in exists... it's like an if else statement?????
HELP !!! Thanks again ..