|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
check user not registered before submitting data
Hi!
I have a form which submits data to a hidden page. The first thing I need to do on the hidden page is check that the user has not already completed the form and is not on our db already. I am using the National Ins number to check. I do a select to check whether that number is found, if it isn't then it submits data, otherwise it prints a table with 'already registered'. It seems to submit the data, but does not see to be chcking correctly as, when I enter a NINumber within the db, it just submits and doesn't bring up 'already registered'. Can anyone spot the problem? Appreciate this! Lee <%@ Language=VBScript %> <%Response.Buffer=True%> <head><title>Active Ideas</title></head> <BODY> <!-- #include file = "ADOVBS.INC" --> <% Dim strTitle, strFirstName, strSurname, strNINumber Dim cndb, cmdcheckuser, cmdaddtodatabase, cmdretrievefromdb, rsrecordsretrieved, rscheckuser Response.Expires=0 %> <% strTitle=Request.Form("Title") strFirstName=Trim(Request.Form("FirstName")) strSurname=Trim(Request.Form("Surname")) strNINumber=Trim(Request.Form("NINumber")) Set cndb = server.CreateObject("adodb.connection") Set cmdcheckuser = server.CreateObject("adodb.command") Set cmdaddtodatabase = server.CreateObject("adodb.command") Set cmdretrievefromdb = server.CreateObject("adodb.command") Set rsrecordsretrieved = server.CreateObject("adodb.recordset") Set rscheckuser = server.CreateObject("adodb.recordset") cndb.CommandTimeout = 15 cndb.CursorLocation = adUseServer cndb.ConnectionString = "DSN=cjrcls" 'this is for local 'cndb.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=d:\webs/fz****/db/****.mdb" on error resume next cndb.Mode = 3 '3 = adModeReadWrite cndb.open if err <> 0 then response.write "Error connecting to the database" response.end end if With cmdcheckuser .CommandTimeout = 15 set .ActiveConnection = cndb .CommandType = adCmdText .CommandText = "SELECT NINumber FROM ApplicantDetails WHERE NINumber = '" & strNINumber & "';" End with rscheckuser.Open cmdcheckuser,,adOpenStatic,adLockOptimistic on error resume next if err.number <> 0 then response.write "error connecting to database<br>" &_ "Error: " & err.Description response.end end if if rsrecordsretrieved.RecordCount = 0 then With cmdaddtodatabase .CommandTimeout = 15 set .ActiveConnection = cndb .CommandType = adCmdText .CommandText = "INSERT INTO ApplicantDetails (Title, FirstName, Surname) VALUES ('"&strTitle&"','"&strFirstName&"','"&strSurname&"')" .Parameters.Append(.CreateParameter ("pTitle", adVarChar,adParamInput,50, strTitle)) .Parameters.Append(.CreateParameter ("pFirstName", adVarChar,adParamInput,50, strFirstName)) .Parameters.Append(.CreateParameter ("pSurname", adVarChar,adParamInput,50, strSurname)) on error resume next .Execute if err.number <> 0 then Response.write err.description Response.End end if if err.number = 0 then Response.Redirect("process.asp") Response.End end if End with else %> <table width="100%"> <tr><td>you're already registered!</td></tr> </table> </body> </html> <%end if%> |
|
#2
|
||||
|
||||
|
SELECT NINumber FROM ApplicantDetails WHERE NINumber = '" & strNINumber & "';
why is NI Number a string? Shouldnt it be a number? |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ASP Programming > check user not registered before submitting data |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|