You need to set up a microsite page that handles the form submission and does something with the values. AMPscript has a function RequestParameter()
that gets values from an HTTP Post. You take these values and insert them into your DE.
A Really Simple Example
Here is the simplest example I can think of to do what you need. You will have 2 microsite pages: Form, which contains the actual HTML form, and Handle Form which handles the HTTP Post and inserts the values into your DE.
Form
<html>
<form id="myForm" method="post" action="/url/to/handle/form">
<input type="hidden" name="firstname" value="Jon" />
<input type="radio" name="beer" value="lager" />Lager<br />
<input type="radio" name="beer" value="ipa" />IPA
<input type="submit" />
</form>
</html>
Note: you need to replace the form's action
attribute with the URL to your Handle Form page
Handle Form
%%[
set @beer = RequestParameter("beer")
set @firstname = RequestParameter("firstname")
InsertData("Some Data Extension","beer",@beer,"firstname",@firstname,"Date",Now())
]%%
%%=v(@beer)=%%
<br />
%%=v(@firstname)=%%
The above example will work, but it's not great because it does not contain any validation and requires the user to navigate back if there is an issue. ExactTarget has some documentation on validating forms which can be read here: Using AMPscript to Validate Fields in a Landing Page
A More Advanced Example
This example might be beyond the scope of your question but I want to share it as it might help someone down the road. As someone who's done this more than few times in SFMC I prefer to use ajax to submit and handle the form. The Handle Form page is requested using JavaScript and has a content type of application/json
. You would select JavaScript Object Notation (JSON) from the Content Type dropdown when creating your page.
The content of your Handle Form page would look something like the code below. It looks for the required values and if they are present it inserts into the DE and returns success as true. Otherwise it returns false allowing you to handle the error appropriately on the front end. Using JavaScript to handle the form in this way will allow you to to provide a better user experience for whoever is using your site.
%%[
set @success = true
set @beer = RequestParameter("beer")
set @firstname = RequestParameter("firstname")
if Empty(@beer) or Empty(@firstname) then
set @success = false
else
InsertData("Some Data Extension","beer",@beer,"firstname",@firstname,"Date",Now())
endif
]%%
{
"success" : "%%=v(@success)=%%"
}