For most of my sites, this is the ocde I use and I would like to convert this to Stored Procedures using paramtised variables
<%
'Response.Write DB_con
'Response.End ()
p_username = Request.Form ("username")
p_password = Lcase(Request.Form ("password"))
Session ("username") = p_username
Set MyConn=Server.CreateObject
("ADODB.Co
nnection")
'Response.Write DB_Con
'Response.End
MyConn.Open DB_Con
MySQL="Select * from tbl_admin Where username = '" & p_username & "'"
Set MyRs=MyConn.Execute(MySQL)
if MyRs.EOF then
'There is no such email and so the recordset is empty
Response.Redirect "default.asp?retry=usernam
e"
else
'the username is valid, now check the password
real_password = trim (MyRs("password"))
'compare the recordset field for password with the database field for password
if p_password = real_password then
'the password is good
dim dob
'dob = MyRS("dob")
'Response.Write dob
'Response.End
Response.Cookies ("adminisloggedin")("usern
ame") = p_username
Response.Cookies ("adminisloggedin")("first
name") = MyRs("firstname")
Response.Cookies ("adminisloggedin")("lastn
ame") = MyRs("lastname")
Response.Cookies ("adminisloggedin")("rank"
)=MyRS("ra
nk")
Response.Cookies ("adminisloggedin")("dateo
flogin") = MyRS("dateoflastlogin")
recordtoupdate = MyRS("autoid")
'if p_save = "yes" then
' Response.Cookies ("isloggedin").expires = #December 31, 2002 00:00:00#
'end if
'Report the date of login into the database.
Dim objRecordset
Set objRecordset = Server.CreateObject("ADODB
.Recordset
")
objRecordset.Open "tbl_admin", DB_CON, adOpenKeyset, adLockPessimistic, adCmdTable
iRecordToUpdate = Cint(recordtoupdate)
If iRecordToUpdate <> 0 Then
If Not objRecordset.EOF Then
objRecordset.MoveFirst
Do Until objRecordset.Fields("autoi
d") = iRecordToUpdate
objRecordset.MoveNext
Loop
' String / Text Data Type
ObjRecordset.Fields("dateo
flastlogin
") = date
objRecordset.Update
End If
End If
Response.Redirect "frame.asp"
else
'the username is valid but the password is incorrect
Response.Redirect "default.asp?retry=passwor
d"
end if
end if
MyRs.close
Set MyRs= Nothing
MyConn.Close
set MyConn=nothing%>
I would like some one to help me re write this code with stored procedures for the log in routine.
Start Free Trial