Forums

Push $_POST to Thank you page

buddyq 15 Nov, 2009
Hi there,

My form is working just fine and I am using the redirect url to go to a thank you page. I would like to have some variables from the form on the thank you page such as:

You requested date is: $_POST['date']

Also, so I can show a link to new patient forms if they have selected 'Yes' from a question in the form. I can't figure out how I get use these variables in my thank you page.

Please help.
nml375 15 Nov, 2009
Hi,
Since you redirect, there's no practical way to attach form data to the redirect, other than "GET-style" URL-encoding them. To do this with ChronoForms, you'd have to use some custom code, as the Redirect-control in the form setup does not allow dynamic values to be entered.

The following code will add a parameter named 'date', containing the value of the previously submitted parameter 'date', to the URL stored in the Redirect control. It should be added to the "on Submit - after email" control.
<?
$url = JFactory::getURI($MyForm->formrow->redirecturl);
$url->setVar('date', JRequest::getVar('date', '', 'post'));
$MyForm->formrow->redirecturl = $uri->toString();
?>


/Fredrik
buddyq 16 Nov, 2009
Is there a way to add these vars to the session and then read those variables from the thank you page and then drop them from the session after they've been written to the page?

Buddy
nml375 16 Nov, 2009
Hi,
As long as you're redirecting within the same site, the session storage should work very well.

To store the data:
<?
$sess =& JFactory::getSession();
$sess->set('date', JRequest::getVar('date', '', 'post'));
?>


To retrieve the data stored:
<?
$sess =& JFactory::getSession();
$date =& $sess->get('date', '');
?>


To remove the data from the session storage:
<?
$sess =& JFactory::getSession();
$sess->clear('date');
?>


/Fredrik
buddyq 16 Nov, 2009
Thank you for the quick response. This is all within the same site so this should work well. I will give this a try and report back but this looks very promising.

Much thanks!
This topic is locked and no more replies can be posted.