The short version: I've got a database where employees are required to enter a client's email address in order to get started.
I'm working on an asp script to check that email against the existing database to make sure it doesn't already exist.
Using either a Response.Redirect on error, or a Server.Transfer on success (IE: the email doesn't already exist)
I've set the column we're inserting to be unique in the SQL database, but every time I enter any email, I always get the error page, never the server.transfer. My code is below, I'm ommitting things like my server connection info (its stored in a separate asp page so I don't have to constantly call it. I'm using the server.transfer method because it retains the values in the earlier entered form, so I can autopopulate part of the form on the next page.
So, what am I missing here? Theoretically, if the email is already in the db, you get redirected back to the original page : addclient.asp : with an error message displayed. If the email is NOT in the db, you should get pushed to the second page : addclient2.asp : which is another form for name, address, phone, etc.
<!--#INCLUDE FILE="databaseconnectionSQL.asp" -->
userid = session("userid")
If Len(userid) = 0 Then
response.redirect("login.asp?msg=Your Session is expired. Please Log-in again.")
On Error Resume Next
Dim strNewClientEmail, strEmpID, rs, strSQL
strNewClientEmail = Request.Form("newclientemail")
strEmpID = Session("empid")
strSQL = "INSERT (rep_id, client_email) INTO client VALUES('" & strEmpID & "' , '" & strNewClientEmail & "')"
set rs = RD.execute(strSQL)
if err.number <> 0 then
Response.Redirect("addclient.asp?error=This Email is already in our database")
Thanks for any help or pointers you can give me!!