***** http://www.target1.com/survey/address.asp

<% 
Msg=""
'Action = Left(UCase(Request("Action")),5)
More = Request( "morequestions.x" )

Dim textvars()
Dim textvals()
ReDim textvars( 11 )
ReDim textvals( 11 )

textvars(0) = "firstname"
textvars(1) = "mi"
textvars(2) = "lastname" 
textvars(3) = "city" 
textvars(4) = "zip" 
textvars(5) = "email" 

' These are not actually textvars, but they are included for completeness.
textvars(6) = "state"
textvars(7) = "home_address_line1" 
textvars(8) = "home_address_line2" 
textvars(9) = "sendoffers"
textvars(10) = "sendemail" 
textvars(11) = "target1_id"

'validate email address
If More = "" Then
	junk = 1
Else
	If InStr(Request("email"), "@") = 0  Then 
		Msg = "You must enter an e-mail address in order to proceed!"
	Else
		Msg = ""
	End If
End If

'validate text fields for empty data
' data can contain ' char
'This loop may be useful for some other validation, if required.

'If More <> "" AND Msg = "" Then
'       For i = 0 To 5
'               var = Request( textvars(i) )
'               If var <> "" AND ( InStr( var, "'" ) <> 0 ) Then
'                       Msg = var & ": contains invalid characters"
'                       Exit For
'               Else
'                       Msg = ""
'               End If
'       Next
'End If


'If inputs are proper Then load them into database.
If ( More = "" ) Then
	junk = 1
ElseIf ( Msg = "" ) Then
	For i = 0 To 11
		textvals(i) = ""
	Next

	Set Conn = Server.CreateObject("ADODB.Connection")
	Set RSADR = Server.CreateObject( "ADODB.RecordSet" ) 
	Conn.Open Session("ConnectionString")

	sql = "select * from to_address where target1_id = " & CLng( Session( "target1_id" ) )
	RSADR.Open sql, Conn, 1, 3
	present = False
	Do While not RSADR.EOF
		present = True
		For i = 0 To 5 
			var = Request( textvars(i) )
			If  var = "" Then
				textvals(i) = RSADR( textvars(i) )
			Else
				textvals(i) = var
			End If
		Next
		Exit Do
	LOOP
	If present = False Then
		For i = 0 To 5
			textvals(i) = Request( textvars(i) )
		Next
	End If

	For i = 6 to 10 
		textvals(i) = Request( textvars(i) )
	Next
	textvals(11) = Session( "target1_id" )

	'RSADR.Open "to_address", Conn, 3, 3
	If present = True Then
		'update
		ReDim Preserve textvars(12)
		ReDim Preserve textvals(12)
		textvars(12) = "modify_date"
		textvals(12) = Now
		RSADR.Update textvars, textvals
	Else
		'insert
		ReDim Preserve textvars(13)
		ReDim Preserve textvals(13)
		textvars(12) = "creation_date"
		textvars(13) = "modify_date"
		textvals(12) = Now
		textvals(13) = Now
		RSADR.AddNew 
		RSADR.Update textvars, textvals
	End If
	RSADR.Close
	Conn.Close
	Response.Redirect( "/" & Session( "target1dir" ) & "/Questions.asp" )
End If
site = Session( "site" )
target1dir = Session( "target1dir" )
%>
<HTML>
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<BODY BGCOLOR="#FFFFFF"><BR><TITLE> Target1 </TITLE>
<HEAD><TITLE>Feedback Survey</TITLE> </HEAD>
<center><img src="/<%=target1dir%>/<%=site%>/header.gif"></center>
<BR>
<h3><center><%=Msg%></center></h3>
<FORM name=address method="POST" action="address.asp">
<TABLE>
<TR>
<TD>First Name:</TD>
<TD><input name="firstname" value = "<%=Request( "firstname" )%>" size=30 maxlength=30></TD>
</TR><TR>
<TD>Middle Initial:</TD>
<TD><input name="mi" value = "<%=Request( "mi" )%>" size=1 maxlength=1</TD>
</TR><TR>
<TD>Last Name: </TD>
<TD><input name="lastname" value = "<%=Request( "lastname" )%>" size=30 maxlength=30</TD>
</TR><TR>
<TD>Home Address (line 1):</TD>
<% 
If Session( "cookieid" ) = "DEMOPPID"  Then
	If Request( "home_address_line1" ) = "" Then
		add1 = "1600 Pennsylvania Av"
	Else
		add1 = Request( "home_address_line1" )
	End If
	If Request( "city" ) = "" Then
		city = "Washington D.C."
	Else
		city = Request( "city" )
	End If
	If Request( "state" ) = "" Then
		state = "Washington"
	Else
		state = Request( "state" )
	End If
	If Request( "zip" ) = "" Then
		zip = "20001"
	Else
		zip = Request( "zip" )
	End If
	If Request( "email" ) = "" Then
		email = "demo@target1.com"
	Else
		email = Request( "email" )
	End If
End If
%>
<TD><input name="home_address_line1" value = "<%=add1%>" size=30 maxlength=30></TD>
</TR><TR>
<TD>Home Address (line 2):</TD>
<TD><input name="home_address_line2" value = "<%=Request( "home_address_line2" )%>" size=30 maxlength=30></TD>
</TR><TR>
<TD>City: </TD>
<TD><input name="city" value = "<%=city%>" size=30 maxlength=30></TD>
</TR><TR>
<TD>State: </TD>
<TD>
<select name="state">
<option value=AK>Alaska
<option value=AL>Alabama
<option value=AR>Arkansas
<option value=AZ>Arizona
<option value=CA>California
<option value=CO>Colorado
<option value=CT>Connecticut
<option value=DC>District
<option value=DE>Delaware
<option value=FL>Florida
<option value=GA>Georgia
<option value=HI>Hawaii
<option value=IA>Iowa
<option value=ID>Idaho
<option value=IL>Illinois
<option value=IN>Indiana
<option value=KS>Kansas
<option value=KY>Kentucky
<option value=LA>Louisiana
<option value=MA>Massachusetts
<option value=MD>Maryland
<option value=ME>Maine
<option value=MI>Michigan
<option value=MN>Minnesota
<option value=MO>Missouri
<option value=MS>Mississippi
<option value=MT>Montana
<option value=NC>North Carolina
<option value=ND>North Dakota
<option value=NE>Nebraska
<option value=NH>New Hampshire
<option value=NJ>New Jersey
<option value=NM>New Mexico
<option value=NV>Nevada
<option value=NY>New York
<option value=OH>Ohio
<option value=OK>Oklahoma
<option value=OR>Oregon
<option value=PA>Pennsylvania
<option value=RI>Rhode Island
<option value=SC>South Carolina
<option value=SD>South Dakota
<option value=TN>Tennessee
<option value=TX>Texas
<option value=UT>Utah
<option value=VA>Virginia
<option value=VT>Vermont
<option value=WA>Washington
<option value=WI>Wisconsin
<option value=WV>West Virginia
<option value=WY>Wyoming
</select></TD>
</TR><TR>
<TD>Zip: </TD>
<TD><input name="zip" value = "<%=zip%>" size=10 maxlength=10 ></TD>
</TR>
<TR>
<TD>
<% If Msg = "" Then %>
What is your e-mail address:
<% Else %>
<b>What is your e-mail address:</b>
<%End If %>
</TD>
<TD><input name="email" value = "<%=email%>" size=30 maxlength=30></TD>
</TR><TR>
<TD>Please E-mail offers that might be of interest to me when they are available</TD>
<TD><SELECT Name=sendemail>
<option value=Y> Yes
<option value=N> No
</SELECT></TD></TR>
<TR><TD>Please forward direct mail offers that might be of interest to me when they are available</TD>
<TD><SELECT Name=sendoffers>
<option value=Y>Yes
<option value=N>No
</SELECT></TD></TR>
<TR>
<!--<TD><h3>More Questions?</h3></td>-->
<TD align=left><INPUT TYPE=image SRC="/<%=target1dir%>/<%=site%>/leftbutton.gif" name="morequestions" value="Press for More Questions"></TD>
<!--<TD><INPUT TYPE=SUBMIT  NAME="Action" VALUE="Press for More Questions"></TD>-->
<TD><input type="reset" name="tosurvey" value="Reset"></TD>
</TR>
</TABLE>
</FORM>
</BODY>
</HTML>
