IIS ASP - prevent duplicate submissions to a database from an ASP form

This is Interesting: Free IT Magazines  
Home > Archive > IIS ASP > July 2005 > prevent duplicate submissions to a database from an ASP form





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author prevent duplicate submissions to a database from an ASP form
Sandra G

2005-07-27, 8:48 pm

I need help ASAP. I have a form where users can fill out the fields
firstname, lastname, and emailaddress. When the user submits the form,
I need ASP to call out to a SQL Server database to see if the
firstname, lastname and emailaddress the user submitted already exists
in the database. If they all do exist, the user should not be allowed
to submit the data but should be redirected to a page saying "sorry,
you have already entered that information" or something to that effect.

Thanks!

Ray Costanzo [MVP]

2005-07-28, 2:50 am

First name, last name, ~and~ e-mail? Typically an e-mail address by itself
is all you'd want to use. By checking all three, that would mean I could
register on your site as many times as I like with the same e-mail address.
All I'd have to do is change my name each time. But, I'm not your father.

Dim oADO, oRS, sSQL
Dim sFirstname, sLastname, sEmail

sFirstname = Request.Form("firstname")
sLastname = Request.Form("lastname")
sEmail = Request.Form("email")
sSQL = "SELECT email FROM yourtable WHERE Lastname=" & dbIn(sLastname) & "
AND Firstname=" & dbIn(sFirstname) & " AND Email=" & dbIn(sEmail)

Set oADO = CreateObject("ADODB.Connection")
oADO.Open yourConnectionstring
Set oRS = oADO.Execute(sSQL)
If oRS.EOF Then
''fine, not an exact match, insert the data next
Else
Response.Write "You exist."
End If
oRS.Close : Set oRS = Nothing
oADO.Close : Set oADO = Nothing


Function dbIn(s)
dbIn = "'" & Replace(s, "'", "''") & "'"
End Function


Ray at home



"Sandra G" <gruskysca@yahoo.com> wrote in message
news:1122511789.803137.55050@g43g2000cwa.googlegroups.com...
>I need help ASAP. I have a form where users can fill out the fields
> firstname, lastname, and emailaddress. When the user submits the form,
> I need ASP to call out to a SQL Server database to see if the
> firstname, lastname and emailaddress the user submitted already exists
> in the database. If they all do exist, the user should not be allowed
> to submit the data but should be redirected to a page saying "sorry,
> you have already entered that information" or something to that effect.
>
> Thanks!
>



Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com