background shape
background shape

How to properly handle form submission

On many occasions when handling any form submission single cloud page application is used. This is great as all of error handling, form submission and processing is on one page so it is actually simpler to implement. But here are some thing you need to take into consideration.

Handle GET form submissions

I have seen lots of cloud pages made in a way that i could easily submit the form via the get request.

%%[
SET @submit =  RequestParameter("submit")
IF  NOT EMPTY(@submit) THEN
	//process the form
END IF
]%%

You can easily submit the form with the url parameters:

example.com?submit=22

This can be avoided by asking if the request is POST

<script runat="server">
    Platform.Load("core","1.1.1");
    Variable.SetValue('@request', Platform.Request.Method);
</script>
%%[
SET @submit =  RequestParameter("submit")
IF  NOT EMPTY(@submit) AND @request == "POAST" THEN
	//process the form
END IF
]%%

Accidental form resubmission

When form is processed you want to show user that the information has been successfully saved. You somehow refresh the page and resubmit the form again. This can be easily solved by redirecting user after form has been successfully saved to another success cloud page

SET @successPage = 333 //success page id
IF  NOT EMPTY(@submit) AND @request == "POAST" THEN
	//process the form
	Redirect(CloudPagesURL(@successPage, 'param','value')) 
END IF

Another possible enhancements that can be done to our cloud page form submission is to add recaptcha

Oh hi there 👋
I have a FREE e-book for you.

Sign up now to get an in-depth analysis of Adobe and Salesforce Marketing Clouds!

We don’t spam! Read our privacy policy for more info.

Share With Others

Leave a Comment

Your email address will not be published. Required fields are marked *

MarTech consultant

Marcel Szimonisz

Marcel Szimonisz

I specialize in solving problems, automating processes, and driving innovation through major marketing automation platforms.

Buy me a coffee