invision
12-05-2007, 05:43 AM
Hello,
I have the following script which I wish to determine if the sql query results in one result. If so, it has found a match on the database, and it will login the user to the system.
<%
Sub CheckLoginForm
Dim username, password
username = trim(Request.Form("username")
password = trim(Request.Form("password")
Sub DatabaseConnect
'declare your variables
Dim Connection, sConnString, SQL, Recordset
'declare SQL statement that will query the database
SQL = "SELECT * FROM clients WHERE username = trim(username) AND trim(password) LIMIT 1"
'create ADO connection and recordset object
Set Connection = Server.CreateObject("ADODB.Connection")
Set Recordset = Server.CreateObject("ADODB.Recordset")
'define connection string, specify database driver and location of database
sConnString="PROVIDER=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & Server.MapPath("db/mytempsite.mdb")
'Open the connection to the database
Connection.Open(sConnString)
'Open recordset object executing the SQL statement & returning the records
Recordset.Open SQL, connection
conn.Execute SQL
End Sub
<!-- if number of rows matched equals 1 then log them in-->
If rowcount(SQL) == 1 Then //////////////////////////////////////////////
Session("BlnLoggedIn") = True
Session("Username") = trim(Request.Form("username")
Response.Redirect "index.asp"
Else
'if the values entered are incorrect then display the message below
Response.Write "<div align='center'>You are not logged in.</div><br>"
ShowLoginForm
End If
End Sub
%>
If anyone can help me with this, it'd be fantastic. Thanks!
I have the following script which I wish to determine if the sql query results in one result. If so, it has found a match on the database, and it will login the user to the system.
<%
Sub CheckLoginForm
Dim username, password
username = trim(Request.Form("username")
password = trim(Request.Form("password")
Sub DatabaseConnect
'declare your variables
Dim Connection, sConnString, SQL, Recordset
'declare SQL statement that will query the database
SQL = "SELECT * FROM clients WHERE username = trim(username) AND trim(password) LIMIT 1"
'create ADO connection and recordset object
Set Connection = Server.CreateObject("ADODB.Connection")
Set Recordset = Server.CreateObject("ADODB.Recordset")
'define connection string, specify database driver and location of database
sConnString="PROVIDER=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & Server.MapPath("db/mytempsite.mdb")
'Open the connection to the database
Connection.Open(sConnString)
'Open recordset object executing the SQL statement & returning the records
Recordset.Open SQL, connection
conn.Execute SQL
End Sub
<!-- if number of rows matched equals 1 then log them in-->
If rowcount(SQL) == 1 Then //////////////////////////////////////////////
Session("BlnLoggedIn") = True
Session("Username") = trim(Request.Form("username")
Response.Redirect "index.asp"
Else
'if the values entered are incorrect then display the message below
Response.Write "<div align='center'>You are not logged in.</div><br>"
ShowLoginForm
End If
End Sub
%>
If anyone can help me with this, it'd be fantastic. Thanks!