Thread tagged as: Question, Problem, Forms

Reuse input data from form within success

Is it possible to output the data from a form within the success message or indeed elsewhere?

For example within the form:

<perch:input type="checkbox" id="priceSelect" value="<perch:content id="price"/>">

Then in the success message out put the price that was entered:

<perch:input id="priceSelect" />
<input type="hidden" name="amount" value="<perch:input id="priceSelect" />">

This obviously outputs another input box, albeit with the correct data within it. How can I get that data into a regular <perch:content> field?

Rob Saunders

Rob Saunders 0 points

  • 3 years ago

Is this possible? Any way to display the data that has been entered into a form within the success message?

Drew McLellan

Drew McLellan 2638 points
Perch Support

You'd need to grab the value from $_POST and pass it back into the template in order to do that.

Excellent! Thank you for pointing me in the right direction.

Used this to pass data down so essentially had one form that passes data into the CMS but also populates the success message where there is an option to go to PayPal to make the payment.

  $form = $_POST;
  $priceSelect = $form['selectPrice'];
  $priceOther = $form['otherPrice'];

  if ($priceSelect >= '1') {
    PerchSystem::set_var('price', $priceSelect);
  } else {
    PerchSystem::set_var('price', $priceOther);