<%@ LANGUAGE="VBScript" %> <%Option Explicit%> <% Dim con, rs, strSql If Request.Form("cmdSubmit") <> "" Then 'The user has submitted the page, so process the Newsletter subscription request 'Connect to the database Set con = GetDBConnection() 'Verify that the email address does not already exist in the database strSql = "SELECT * FROM Subscribers WHERE Email = '" + Request.Form("txtEmail") + "'" Set rs = Server.CreateObject("ADODB.Recordset") rs.Open strSql, con, 1, 2 If rs.EOF Then 'The email address does not already exist, so add it rs.AddNew() rs("Email") = Request.Form("txtEmail") rs("City") = Request.Form("txtCity") rs("Zip") = Request.Form("txtZip") rs.Update() 'The email address has been added, show confirmation. 'MODIFY the text below is displayed when an email is added to the newsletter %> 'Successfully added to the newsletter <% Else 'The email address already exists in the database 'MODIFY the text below is displayed when a person tries to enter the same email address ' a second time. %> 'You have already been added to the newsletter, thanks for your interest. <% End If 'Clean up database objects rs.Close() Set rs = Nothing con.Close() Set con = Nothing Else 'MODIFY the text below is displayed when the page is first loaded. %>
Enter your email address to subscribe:
 
City:
 
Zip Code:

<% End If %>