Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

If-Then-Else statement on forms

Status
Not open for further replies.

DeepBlerg

Technical User
Jan 13, 2001
224
AU
Hi,

I'm having trouble with some ASP script.
Here it is:

<%
fname=request.form(&quot;name&quot;)
email1=request.form(&quot;email1&quot;)
country=request.form(&quot;country&quot;)
company=request.form(&quot;company&quot;)

Set dbconnection = Server.CreateObject(&quot;ADODB.Connection&quot;)
dbconnection.open &quot;DSN=fdatabase&quot;

Set RS_Users = Server.CreateObject(&quot;ADODB.Recordset&quot;)

RS_Users.ActiveConnection = dbconnection
RS_Users.Source = &quot;ftable&quot;
RS_Users.CursorType = 1
RS_Users.CursorLocation = 2
RS_Users.LockType = 2
RS_Users.Source = &quot;fdatabase&quot;

SQL_Users = &quot;Select * from ftable&quot;
RS_Users.Open SQL_Users

Do while not RS_Users.eof

If RS_Users(&quot;email&quot;) = email1 then
response.redirect(&quot;existinguser.htm&quot;)
else
RS_Users.AddNew
RS_Users(&quot;name&quot;) = name
RS_Users(&quot;email&quot;) = email1
RS_Users(&quot;country&quot;) = country
RS_Users(&quot;company&quot;) = company
RS_Users.Update
End If
RS_Users.movenext
loop
RS_Users.close
Set RS_Users=Nothing
dbconnection.close
%>

The script works if email1 is not in the database, but if an email address is typed that is in the database it still adds it as a new record.

Any help would be greatly appreciated.

--Tim
 
Tim,

You could do this.

SQL_Users = &quot;Select * from ftable where email = '&quot; &amp; email1 &amp; &quot;'&quot;

If RS_Users.eof then
' Add new record
else
response.redirect(&quot;existinguser.htm&quot;)
end if

Good luck
-pete


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top