gerjan
06-26-2003, 07:16 AM
Check if value already exist.
I’ve written a script for a newsletter.
Works fine, except some visitors subscribe themselves more than one’s.
I can prevent that to check if a field already contains a value.
I thought I put a check before the e-mail will be added.
But somehow I get errors when I add two times a sql statement in my code.
Could somebody explain me how to do this?
I put the code (without the check, because it don’t work) as an attachment.
'THIS IS THE CODE I TRIED TO PUT BEFORE INSERT STATEMENT, BUT GENERATES AN ERROR (somehow because I have 2 statements?)!
sqstringcheck = "SELECT * FROM nieuwsbrief WHERE email = '"&email&"'"
set objRScheck = objConn.execute (sqstringcheck)
set emailcheck = objRScheck("email")
if emailcheck <> "" then
response.redirect "../../nieuwsbrief.asp?fout=exist"
end if
sqstringcheck.close
set sqstringcheck = nothing
I’ve written a script for a newsletter.
Works fine, except some visitors subscribe themselves more than one’s.
I can prevent that to check if a field already contains a value.
I thought I put a check before the e-mail will be added.
But somehow I get errors when I add two times a sql statement in my code.
Could somebody explain me how to do this?
I put the code (without the check, because it don’t work) as an attachment.
'THIS IS THE CODE I TRIED TO PUT BEFORE INSERT STATEMENT, BUT GENERATES AN ERROR (somehow because I have 2 statements?)!
sqstringcheck = "SELECT * FROM nieuwsbrief WHERE email = '"&email&"'"
set objRScheck = objConn.execute (sqstringcheck)
set emailcheck = objRScheck("email")
if emailcheck <> "" then
response.redirect "../../nieuwsbrief.asp?fout=exist"
end if
sqstringcheck.close
set sqstringcheck = nothing