ASP Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreASP Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 12th, 2003, 12:52 PM
leeolive leeolive is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: London
Posts: 43 leeolive User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
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%>

Reply With Quote
  #2  
Old October 12th, 2003, 02:14 PM
Utopia's Avatar
Utopia Utopia is offline
superficial
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2002
Location: Peterborough, England
Posts: 188 Utopia User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 36 m 8 sec
Reputation Power: 7
SELECT NINumber FROM ApplicantDetails WHERE NINumber = '" & strNINumber & "';

why is NI Number a string? Shouldnt it be a number?

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreASP Programming > check user not registered before submitting data


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway