Is it possible to have a custom form write the results into a data extension? The form will have a Name field, an Event Type (dropdown), and a Promotion Type (Checkbox). I have a data extension setup with those fields already.
closed as too broad by Adam Spriggs, Sebastian Kessel, Reshma, glls, Derek F Mar 12 at 11:29
Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
It's possible. You didn't specify where your custom form would reside, so I'm going to use a pair of CloudPages for a BARE-BONES (i.e., no fancy JS) example. We'll need:
- A page that contains the form
- A page that receives/processes the data
- A data extension that stores the data
- AMPscript Sites functions
- AMPscript Data Extension functions
The form page
<!doctype html> <html> <head> <title></title> </head> <body> <form action="https://my-processing-page" method="POST"> Name:<br> <input type="text" name="name"><br> Event Type:<br> <select name="eventtype"> <option value="foo">Foo</option> <option value="bar">Bar</option> </select><br> Promotion Type:<br> <input type="checkbox" name="promotype" value="baz"> Baz <br> <button>Submit</button> </form> </body> </html>
The processing page
%%[ var @eventType, @insertData, @name, @promoType /* store incoming form values to AMPscript variables */ set @name = RequestParameter('name') set @eventType = RequestParameter('eventtype') set @promoType = RequestParameter('promotype') if not Empty(@name) and not Empty(@eventType) and not Empty(@promoType) then set @insertData = InsertData( 'My Custom Form Data', 'Name', @name, 'Event Type', @eventType, 'Promotion Type', @promoType ) if (@insertData == 1) then ]%% Data was successfully saved. %%[ else ]%% Could not save data. %%[ endif else ]%% All form fields required, please go back. %%[ endif ]%%
While this example should work, there is much MUCH more to be done still (e.g., form validation, applying web security best practices, etc.), but this can get you started.