<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>My Form</title>
</head>
<body>
<form name="myForm" id="myForm" method="POST" action="%%= RequestParameter('PAGEURL') =%%">
<input type="hidden" name="__successPage" id="__successPage" value="http://pages.mysuccesspage.php" />
<input type="hidden" name="__errorPage" id="__errorPage" value="http://pages.myerrorpage.php" />
<input type="hidden" name="__contextName" id="__contextName" value="FormPost" />
<input type="hidden" name="__executionContext" id="__executionContext" value="Post" />
<table width="600" border="0" cellspacing="0" cellpadding="5">
<tr>
<td width="200">Email Address<span class="requiredColor">*</span></td>
<td width="400"><input id="EmailAddress" name="EmailAddress" maxlength="128" class="formFields longTextFields required" type="email" value="%%=v(@email)=%%" /></td>
</tr>
<tr>
<td>First Name<span class="requiredColor">*</span></td>
<td><input name="FirstName" maxlength="50" id="txtFirstName" class="formFields longTextFields required lettersonly" type="text" value="%%=v(@firstname)=%%" /></td>
</tr>
<tr>
<td>Last Name<span class="requiredColor">*</span></td>
<td><input name="LastName" maxlength="50" id="txtLastName" class="formFields longTextFields required lettersonly" type="text" value="%%=v(@lastname)=%%" /></td>
</tr>
<tr>
<td></td>
<td><input name="submitBtn" type="submit" value="SUBMIT"id="submitBtn" /></td>
</tr>
</table>
</form>
<span style="display: none;" id="post_code">
%%[
[name="FormPost";type="POST"]
/* ADD/UPDATE DATA EXTENSION */
VAR @de, @de_col, @updateOptions, @saveOptions, @de_statusCode, @de_statusMsg, @errorCode
SET @de = CreateObject("DataExtensionObject")
SETObjectProperty(@de, "CustomerKey", "DataExtension")
SET @de_col = CreateObject("APIProperty")
SETObjectProperty(@de_col, "Name", "EmailAddress")
SETObjectProperty(@de_col, "Value", RequestParameter("EmailAddress"))
AddObjectArrayItem(@de, "Keys", @de_col)
IF NOT IsNull(RequestParameter("EmailAddress")) THEN
SET @de_col = CreateObject("APIProperty")
SETObjectProperty(@de_col, "Name", "EmailAddress")
SETObjectProperty(@de_col, "Value", RequestParameter("EmailAddress"))
AddObjectArrayItem(@de, "Properties", @de_col)
ENDIF
IF NOT IsNull(RequestParameter("FirstName")) THEN
SET @de_col = CreateObject("APIProperty")
SETObjectProperty(@de_col, "Name", "FirstName")
SETObjectProperty(@de_col, "Value", RequestParameter("FirstName"))
AddObjectArrayItem(@de, "Properties", @de_col)
ENDIF
IF NOT IsNull(RequestParameter("LastName")) THEN
SET @de_col = CreateObject("APIProperty")
SETObjectProperty(@de_col, "Name", "LastName")
SETObjectProperty(@de_col, "Value", RequestParameter("LastName"))
AddObjectArrayItem(@de, "Properties", @de_col)
ENDIF
SET @de_col = CreateObject("APIProperty")
SETObjectProperty(@de_col, "Name", "FullName")
SETObjectProperty(@de_col, "Value", Concat(RequestParameter("FirstName"), " ", RequestParameter("LastName")))
AddObjectArrayItem(@de, "Properties", @de_col)
/* TRIGGERED SEND */
VAR @ts, @tsDef, @ts_sub, @ts_attr, @tsctr, @ts_subkey, @ts_statusCode, @ts_statusMsg, @errorCode
SET @ts = CreateObject("TriggeredSend")
SET @tsDef = CreateObject("TriggeredSendDefinition")
SET @ts_subkey = RequestParameter("EmailAddress")
SETObjectProperty(@tsDef, "CustomerKey", "TSDefinition")
SETObjectProperty(@ts, "TriggeredSendDefinition", @tsDef)
SET @ts_sub = CreateObject("Subscriber")
SETObjectProperty(@ts_sub, "EmailAddress", RequestParameter("EmailAddress"))
IF NOT EMPTY(@ts_subkey) THEN
SETObjectProperty(@ts_sub, "SubscriberKey", @ts_subkey)
ELSE
SETObjectProperty(@ts_sub, "SubscriberKey", RequestParameter("EmailAddress"))
ENDIF
AddObjectArrayItem(@ts, "Subscribers", @ts_sub)
SET @ts_statusCode = InvokeCreate(@ts, @ts_statusMsg, @errorCode)
IF @ts_statusCode != "OK" THEN
RaiseError(@ts_statusMsg, 0, @ts_statusCode, @errorCode)
ENDIF
ENDIF
SET @updateOptions = CreateObject("UpdateOptions")
SET @saveOptions = CreateObject("SaveOption")
SETObjectProperty(@saveOptions, "PropertyName", "DataExtensionObject")
SETObjectProperty(@saveOptions, "SaveAction", "UpdateAdd")
AddObjectArrayItem(@updateOptions, "SaveOptions", @saveOptions)
SET @de_statusCode = InvokeUpdate(@de, @de_statusMsg, @errorCode, @updateOptions)
IF @de_statusCode != "OK" THEN
RaiseError(@de_statusMsg, 0, @de_statusCode, @errorCode)
ENDIF
]%%
</span>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>My Form</title>
</head>
<body>
<form name="myForm" id="myForm" method="POST" action="%%= RequestParameter('PAGEURL') =%%">
<input type="hidden" name="__successPage" id="__successPage" value="http://pages.mysuccesspage.php" />
<input type="hidden" name="__errorPage" id="__errorPage" value="http://pages.myerrorpage.php" />
<input type="hidden" name="__contextName" id="__contextName" value="FormPost" />
<input type="hidden" name="__executionContext" id="__executionContext" value="Post" />
<table width="600" border="0" cellspacing="0" cellpadding="5">
<tr>
<td width="200">Email Address<span class="requiredColor">*</span></td>
<td width="400"><input id="EmailAddress" name="EmailAddress" maxlength="128" class="formFields longTextFields required" type="email" value="%%=v(@email)=%%" /></td>
</tr>
<tr>
<td>First Name<span class="requiredColor">*</span></td>
<td><input name="FirstName" maxlength="50" id="txtFirstName" class="formFields longTextFields required lettersonly" type="text" value="%%=v(@firstname)=%%" /></td>
</tr>
<tr>
<td>Last Name<span class="requiredColor">*</span></td>
<td><input name="LastName" maxlength="50" id="txtLastName" class="formFields longTextFields required lettersonly" type="text" value="%%=v(@lastname)=%%" /></td>
</tr>
<tr>
<td></td>
<td><input name="submitBtn" type="submit" value="SUBMIT"id="submitBtn" /></td>
</tr>
</table>
</form>
<span style="display: none;" id="post_code">
%%[
[name="FormPost";type="POST"]
/* ADD/UPDATE DATA EXTENSION */
VAR @de, @de_col, @updateOptions, @saveOptions, @de_statusCode, @de_statusMsg, @errorCode
SET @de = CreateObject("DataExtensionObject")
SETObjectProperty(@de, "CustomerKey", "DataExtension")
SET @de_col = CreateObject("APIProperty")
SETObjectProperty(@de_col, "Name", "EmailAddress")
SETObjectProperty(@de_col, "Value", RequestParameter("EmailAddress"))
AddObjectArrayItem(@de, "Keys", @de_col)
IF NOT IsNull(RequestParameter("EmailAddress")) THEN
SET @de_col = CreateObject("APIProperty")
SETObjectProperty(@de_col, "Name", "EmailAddress")
SETObjectProperty(@de_col, "Value", RequestParameter("EmailAddress"))
AddObjectArrayItem(@de, "Properties", @de_col)
ENDIF
IF NOT IsNull(RequestParameter("FirstName")) THEN
SET @de_col = CreateObject("APIProperty")
SETObjectProperty(@de_col, "Name", "FirstName")
SETObjectProperty(@de_col, "Value", RequestParameter("FirstName"))
AddObjectArrayItem(@de, "Properties", @de_col)
ENDIF
IF NOT IsNull(RequestParameter("LastName")) THEN
SET @de_col = CreateObject("APIProperty")
SETObjectProperty(@de_col, "Name", "LastName")
SETObjectProperty(@de_col, "Value", RequestParameter("LastName"))
AddObjectArrayItem(@de, "Properties", @de_col)
ENDIF
SET @de_col = CreateObject("APIProperty")
SETObjectProperty(@de_col, "Name", "FullName")
SETObjectProperty(@de_col, "Value", Concat(RequestParameter("FirstName"), " ", RequestParameter("LastName")))
AddObjectArrayItem(@de, "Properties", @de_col)
/* TRIGGERED SEND */
VAR @ts, @tsDef, @ts_sub, @ts_attr, @tsctr, @ts_subkey, @ts_statusCode, @ts_statusMsg, @errorCode
SET @ts = CreateObject("TriggeredSend")
SET @tsDef = CreateObject("TriggeredSendDefinition")
SET @ts_subkey = RequestParameter("EmailAddress")
SETObjectProperty(@tsDef, "CustomerKey", "TSDefinition")
SETObjectProperty(@ts, "TriggeredSendDefinition", @tsDef)
SET @ts_sub = CreateObject("Subscriber")
SETObjectProperty(@ts_sub, "EmailAddress", RequestParameter("EmailAddress"))
IF NOT EMPTY(@ts_subkey) THEN
SETObjectProperty(@ts_sub, "SubscriberKey", @ts_subkey)
ELSE
SETObjectProperty(@ts_sub, "SubscriberKey", RequestParameter("EmailAddress"))
ENDIF
AddObjectArrayItem(@ts, "Subscribers", @ts_sub)
SET @ts_statusCode = InvokeCreate(@ts, @ts_statusMsg, @errorCode)
IF @ts_statusCode != "OK" THEN
RaiseError(@ts_statusMsg, 0, @ts_statusCode, @errorCode)
ENDIF
ENDIF
SET @updateOptions = CreateObject("UpdateOptions")
SET @saveOptions = CreateObject("SaveOption")
SETObjectProperty(@saveOptions, "PropertyName", "DataExtensionObject")
SETObjectProperty(@saveOptions, "SaveAction", "UpdateAdd")
AddObjectArrayItem(@updateOptions, "SaveOptions", @saveOptions)
SET @de_statusCode = InvokeUpdate(@de, @de_statusMsg, @errorCode, @updateOptions)
IF @de_statusCode != "OK" THEN
RaiseError(@de_statusMsg, 0, @de_statusCode, @errorCode)
ENDIF
]%%
</span>
</body>
</html>