Is it possible to create a form on a landing page where the input field/text area could possibly have ampscript and html code, such as

Hello, %%=v(@first_name)=%%!<br>Welcome to LA.

and write that input to a data extension right from the cloudpage?


Put simply, yes.

You really only need to watch out for your form validation and also realize that it may become encoded by the browser when posting - so special characters may be lost to the HTML entity equivalent.

E.g. '<' would become '&lt;'

I would be very careful when doing this as many different browsers handle and interpret this differently and can potentially corrupt your data. Also, when displaying this content you may need to do some decoding and/or replaces to get the right format/info. The more the info is passed around, the more convoluted it will get.

I would not recommend this for a long term solution, but it is a possibility for the short term.

  • Thank you @Gortonington for your answer. How would you recommend passing the data. I have tried putting the UpdateData ampscript inside of an "onClick" function but realized ampscript is server side language and executed only on page load. The only other option I know is to pass the data to another page to execute the update ampscript. The issue with that is how can I pass the ampscript and/or html snippets without placing them in the url because that will break the link. – Rudy May 23 '17 at 16:47
  • Is the page hosted on SFMC? If so. Have the form post to itself and collect the info Server Side via the RequestParameter() function and then Update. – Gortonington May 23 '17 at 16:55
  • I gave that a try and it works for ampscript like %%=v(@name)=%% but a simple < br > crashes the update. – Rudy May 23 '17 at 18:29
  • you may need to force a URLEncode on it and then decode it when you pull. E.g. set a ReplaceList(ReplaceList(@yourcontent, '<', '&lt;'), '>', '&gt;') – Gortonington May 23 '17 at 18:32
  • %%[ set @ val1 = RequestParameter("name") set@ val2 = RequestParameter("welcome") if @ val2 != "" Then set @ person = lookupRows("People", "Name", @ name) if rowCount(@ person) == 1 then UpdateData("People", 1, "Name", @ name, "Welcome Text", @ val2) endif endif ]%%<br> That is the ampScript I used to update but I think its crashing when the form is collecting the input and it contains html – Rudy May 23 '17 at 18:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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