1

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.

3

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:

  1. A page that contains the form
  2. A page that receives/processes the data
  3. A data extension that stores the data
  4. AMPscript Sites functions
  5. 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.

  • Thanks for the help on this.The form will live on a cloud page like the example you provided. There is a confirmation/summary of the form built into the form so the processing page will just be a "Thank you for submitting" so does that mean this ampscript should live in the form instead of the processing page? This is my confirmation button <div class="text-center"> <button id="editInfo" class="btn" type="button">Edit Info</button> <a id="confirmation" class="btn btn-red" type="submit" href="thank-you-page" role="button">Confirm</a> </div> – Greg Mar 12 at 16:43
  • @Greg the AMPscript will live in a separate processing page that also, in the example above, plays the role of a "thank you" page. If you wanted everything to occur within the confines of a single page, a separate processing page to execute AMPscript will still be required, but you could employ JavaScript to submit the form asynchronousy. That is beyond the scope of the bare-bones example provided. – Mark G Mar 12 at 17:21

Not the answer you're looking for? Browse other questions tagged or ask your own question.