|
Maybe this will help, i adjusted your tabs so that you can see where the nesting end should be, dunno if the code will work but you added one end if to much anyway. here it is.
<!-- Added this Line --> <%
'do server side validation in javascript turned off if strContractedInIndicator = "" or strFirstName = "" then %> <table> this says : please enter required text </table> <% response.end else strContractedInIndicator = "0"
'set command and establish connection 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")
'set connection to local DNS or change to web host DNS cndb.CommandTimeout = 15 cndb.CursorLocation = adUseServer cndb.ConnectionString = "DSN=cjrcls" 'this is for local 'cndb.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=mydatasourceher e.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 * FROM ApplicantDetails WHERE NINumber = '" & strNINumber & "' OR UserName = '" & strUserName & "' OR UserPassword = '" & strUserPassword & "' OR EmailContact = '" & strEmailContact & "';" 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 can't find a record with matching NINumber then user is not in db so submit their details if rscheckuser.EOF = true or rscheckuser.BOF = true then 'pass values as parameters With cmdaddtodatabase .CommandTimeout = 15 set .ActiveConnection = cndb .CommandType = adCmdText .CommandText = "INSERT INTO ApplicantDetails (ContractedInIndicator .....My Note: This all works perfectly..passes parameters etc)
on error resume next .Execute
if err.number <> 0 then Response.write err.description Response.End end if
'if was successfully submitted then redirect to process page with NINumber if err.number = 0 then id = strNINumber Response.redirect "process.asp?id=" & Encrypt(strNINumber) 'added Response.End end if End with
elseif rscheckuser("NINumber") = strNINumber then %> <!-- if persons NINumber has been found in db then tell them they are already registered! --> <table class="bylinefont" width="100%" bgcolor="white" border="0" cellpadding="0" cellspacing="0" align="left" > This says: you are already registered! </table> <% elseif rscheckuser("UserName") = strUserName then %> <table class="bylinefont" width="100%" bgcolor="white" border="0" cellpadding="0" cellspacing="0" align="left"> This says please enter a different username </table> <% elseif rscheckuser("UserPassword") = strUserPassword then %> <table class="bylinefont" width="100%" bgcolor="white" border="0" cellpadding="0" cellspacing="0" align="left"> This says please enter a different password </table> <% elseif rscheckuser("EmailContact") = strEmailContact then %> <table class="bylinefont" width="100%" bgcolor="white" border="0" cellpadding="0" cellspacing="0" align="left"> This says that the email is already in use </table> <% end if end if %>
|