D
David Shorthouse
Bob,
Thanks for providing some URLs in a reply to one of my earlier posts.
Not only have you helped me fix up my site to prevent vbscript injections,
you have shown me how to get a performance boost. I have a question for you
and was wondering if you might be able to help once again. I have almost
completely converted my asp into parameterized requests, but I have one last
problem and that is a "create account" page that checks the Access db for an
existing email address or username, both of which are primary keys in the
db. The code I have tried to use is the following. The code fails at the
email or username check when I try to input an email address or username
that would be a duplicate in the db and always gets through to the create
account append query. Of course, the page throws up an error about there
being duplicate records having the same primary key. The query in the db is
working as expected with its p5 OR p6 parameter requests.
Any ideas?
Dim p1, p2, p3, p4, p5, p6
p1 = Request.Form("GivenName")
p2 = Request.Form("SurName")
p3 = Request.Form("PWD")
p4 = Request.Form("PWD2")
p5 = Request.Form("Email")
p6 = Request.Form("UID")
If LenB(Request.Form("btnAdd")) <> 0 Then
If p3 = p4 Then
Dim DataConnection, RecordSet, strError1, strError2, strError3
Set DataConnection = Server.CreateObject("ADODB.Connection")
DataConnection.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
DatabasePath & ";"
Set RecordSet = Server.CreateObject("ADODB.Recordset")
DataConnection.CheckAccount p5, p6, RecordSet
If Not RecordSet.EOF Then
If RecordSet.Fields("Email") = p5 Then
strError1 = "<FONT FACE='ARIAL' SIZE='3'><B>Sorry, this Email address
is taken.</B></FONT>"
Else
strError2 = "<FONT FACE='ARIAL' SIZE='3'><B>Sorry, this Username is
taken.</B></FONT>"
End if
RecordSet.Close
Set RecordSet=Nothing
DataConnection.Close
Set DataConnection=Nothing
Else
RecordSet.Close
Set RecordSet = Nothing
DataConnection.CreateAccount p1, p2, p3, p5, p6
Session("ID") = p6
DataConnection.Close
Set DataConnection = Nothing
Response.Redirect "createprofile.asp"
Response.End
End if
Else
strError3 = "<FONT FACE='ARIAL' SIZE='3'><B>Sorry, your passwords didn't
match.</B></FONT>"
End If
End if
Thanks for providing some URLs in a reply to one of my earlier posts.
Not only have you helped me fix up my site to prevent vbscript injections,
you have shown me how to get a performance boost. I have a question for you
and was wondering if you might be able to help once again. I have almost
completely converted my asp into parameterized requests, but I have one last
problem and that is a "create account" page that checks the Access db for an
existing email address or username, both of which are primary keys in the
db. The code I have tried to use is the following. The code fails at the
email or username check when I try to input an email address or username
that would be a duplicate in the db and always gets through to the create
account append query. Of course, the page throws up an error about there
being duplicate records having the same primary key. The query in the db is
working as expected with its p5 OR p6 parameter requests.
Any ideas?
Dim p1, p2, p3, p4, p5, p6
p1 = Request.Form("GivenName")
p2 = Request.Form("SurName")
p3 = Request.Form("PWD")
p4 = Request.Form("PWD2")
p5 = Request.Form("Email")
p6 = Request.Form("UID")
If LenB(Request.Form("btnAdd")) <> 0 Then
If p3 = p4 Then
Dim DataConnection, RecordSet, strError1, strError2, strError3
Set DataConnection = Server.CreateObject("ADODB.Connection")
DataConnection.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
DatabasePath & ";"
Set RecordSet = Server.CreateObject("ADODB.Recordset")
DataConnection.CheckAccount p5, p6, RecordSet
If Not RecordSet.EOF Then
If RecordSet.Fields("Email") = p5 Then
strError1 = "<FONT FACE='ARIAL' SIZE='3'><B>Sorry, this Email address
is taken.</B></FONT>"
Else
strError2 = "<FONT FACE='ARIAL' SIZE='3'><B>Sorry, this Username is
taken.</B></FONT>"
End if
RecordSet.Close
Set RecordSet=Nothing
DataConnection.Close
Set DataConnection=Nothing
Else
RecordSet.Close
Set RecordSet = Nothing
DataConnection.CreateAccount p1, p2, p3, p5, p6
Session("ID") = p6
DataConnection.Close
Set DataConnection = Nothing
Response.Redirect "createprofile.asp"
Response.End
End if
Else
strError3 = "<FONT FACE='ARIAL' SIZE='3'><B>Sorry, your passwords didn't
match.</B></FONT>"
End If
End if