[TIP] How to get back to page from where the form was called

moebius 07 Mar, 2009
Hi everybody,

On my website I use a ChronoForm which can be reached from multiple pages. So I was looking a way to get back to the calling page, once the form submitted. I couldn't find a suitable trick to do this this forums or elsewhere on the web, so I post my solution here (it's a hack from the 'Thank you' page question on the FAQ).

First, I add this line to the HTML code of my form :
<input type="hidden" name="referer" value="<?php echo $_SERVER["HTTP_REFERER"];?>" />

This add to the form a hidden field called "refere" and taking the form callin page url as value.

Then, I type these lines to the On Submit code - after sending email ;
<?php
global $mainframe;
$referer = $_POST['referer'];

$custom_tag = '<meta http-equiv="refresh" content="5; url='.$referer.'>';
$mainframe->addCustomHeadTag($custom_tag);
?>
<p>Your message has been sent.</p>

<p>You'll now be redirected to the parent page. If the redirection doesn't work automatically, please click <a href="<?php echo $referer ?>">here</a></p>.


This uses the "referer" fields posted with form to redirect the user to the parent page. Don't forget to leave empty the "Redirect URL:" field in "Form URLs" tab to be sure this trick acts as expected.

Hope this may help.
Max_admin 08 Mar, 2009
Thanks for posting this useful hack!🙂

Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
evetsnalon 25 Oct, 2012

Hi everybody,

On my website I use a ChronoForm which can be reached from multiple pages. So I was looking a way to get back to the calling page, once the form submitted. I couldn't find a suitable trick to do this this forums or elsewhere on the web, so I post my solution here (it's a hack from the 'Thank you' page question on the FAQ).

First, I add this line to the HTML code of my form :

<input type="hidden" name="referer" value="<?php echo $_SERVER["HTTP_REFERER"];?>" />

This add to the form a hidden field called "refere" and taking the form callin page url as value.

Then, I type these lines to the On Submit code - after sending email ;
<?php
global $mainframe;
$referer = $_POST['referer'];

$custom_tag = '<meta http-equiv="refresh" content="5; url='.$referer.'>';
$mainframe->addCustomHeadTag($custom_tag);
?>
<p>Your message has been sent.</p>

<p>You'll now be redirected to the parent page. If the redirection doesn't work automatically, please click <a href="<?php echo $referer ?>">here</a></p>.


This uses the "referer" fields posted with form to redirect the user to the parent page. Don't forget to leave empty the "Redirect URL:" field in "Form URLs" tab to be sure this trick acts as expected.

Hope this may help.




This works great. Does anyone know how to make this work for users that have the Chrome Browser? Seems not to work.

Thanks
GreyHead 18 Nov, 2012
Hi evetsnalon,

I updated the version in this FAQ recently. Have you tried that?

Bob
gardinerj 19 Feb, 2013

I updated the version in this FAQ recently. Have you tried that?


I tried it. What I got was the page starting to redirect, but then tossing an error:
The requested URL /<site url>/index.php; charset=utf-8 was not found on this server.

By the way, the URL is not what was entered in the text of the meta refresh. I used the full qualified site name, or absolute, URL.
GreyHead 19 Feb, 2013
Hi GardinerJ,

There's a Joomla! bug. See this thread on the Joomla! forums where you'll find my bug fix and - probably more useful - a workaround from Skitalec.

Bob
gardinerj 19 Feb, 2013
Used the no-hack approach at the bottom of that thread.

<?php
   $doc = &JFactory::getDocument();
   $doc->addCustomTag('<meta http-equiv="refresh" content="10;url=http://www.mycompany.com" />');
?>

It worked great. Thanks! :-)
This topic is locked and no more replies can be posted.