Hello all I have the below code where it upserts into a DE. I also want to redirect to a new cloud page on clicking submit. The issue is I did find a way to do it by using action="%%=RedirectTo(CloudPagesURL(@optoutRedirect,'id', @id))=%%"
But then it does not upsert into a DE so I lose that functionality. Anyway to make it INSERT into a DE AND also redirect to a new website or cloudpage?
<script runat="server">
Platform.Load("core", "1.1.1");
if (Request.Method == "POST") {
/*var subscriberKey = Request.FormParameter(_susbcriberKey);*/
var subscriberKey = Request.GetQueryStringParameter("sfmc_key");
/*var reason = Request.FormParameter("reason");*/
var reason = Request.GetFormField("reason");
var deName = "Unsubformsubmit_xxxx"; /* Replace with the name of your data extension */
var deRows = Platform.Function.InsertDE(deName, ["SubscriberKey", "reason"], [subscriberKey, reason]);
if (deRows > 0) {
// Success
Platform.Response.Write("Form submitted successfully.");
} else {
// Error
Platform.Response.Write("Error submitting form.");
}
}
</script>
<form method="post">
<select name="reason" id="selectBox" onchange="testfunc();">
<option >1</option>
<option >2</option>
<option >3</option>
<option >4</option>
<option >5</option>
</select> <br>
<textarea style="display:none;" class="text-field" id="textField" name="reason"></textarea> <br>
<button onclick="document.forms[0].submit()" type="submit" class="button">Submit</button>
</form>
<form action=<yourURL>