Forums

Redirect form to no where i.e the same page

funkyrhino 12 Aug, 2011
Hi,

I am using Chronoforms 3.1 with Virtuemart.

All I want to do is set the form so that it does not redirect any where, thus, keeping the virtuemart product page in the browser.

How do I do this - been searching and no luck...

Thanks in advance,

Matt
GreyHead 13 Aug, 2011
Hi Matt,

I think that you probably need to capture the current page url and then set that as the ReDirect URL for the form.

Bob
funkyrhino 13 Aug, 2011
Hi Bob,

Yep, that sounds like exactly what I need to do :-)

...any chance you could point me in the right direction here - is this something I can do within Chronoforms or do I need to look elsewhere for some script to capture the current URL and then somehow feed it back into chronoforms :?

Thanks in advance.

Matt
GreyHead 16 Aug, 2011
Hi Matt,

Not tested but try this.

In the Form HTML
<?php
$url = JFactory::getURI();
?>
<input type='hidden' name='url' id='url' value='<?php echo $url->toString(); ?>' />


In the OnSubmit After Email box as the last item of code:
<?php
$url = JRequest::getString('url', '', 'post');
if ( $url ) { 
  $mainframe->redirect($url);
}
?>
Not tested and may need debugging.

Bob
funkyrhino 16 Aug, 2011
Hi Bob,

Thanks for your help here. It is hugely appreciated.

Unfortunately that code didn't work out for me. Not sure if it needs de-bugging at all?

Are you able to test this code? Also, I can provide you with my website log-in details if you would rather have a look there?

Thanks very much!

Matt
GreyHead 16 Aug, 2011
Hi Matt,

There was a typo - a ] instead of } in the line before last. Now fixed.

It works OK for me in CFv3.2

Bob
funkyrhino 16 Aug, 2011
Hi Bob,

That is working lovely - thanks very much!

I don't suppose there is a way of displaying a message on the form after it has redirected - for example "thank you for..."?

Let me know if you have any ideas?

With thanks as always.

Matt
GreyHead 17 Aug, 2011
Hi Matt,

Replace
$mainframe->redirect($url);
with
$mainframe->redirect($url, 'Thank you for . . .');


Bob
funkyrhino 17 Aug, 2011
Hi Bob,

Thanks very much - that's perfect!

I have ordered you a beer - enjoy!

Matt
brunotrials 19 Aug, 2011
Hello guys!

I would like if this that correct
[attachment=0]current_url.gif[/attachment]
because not work for me, the redirect is OK but no data save in database

thanksšŸ¤£
GreyHead 19 Aug, 2011
Hi brunotrials ,

Yes, that is correct. Do you have a url column in your database table?

Bob
brunotrials 19 Aug, 2011
I do not have the url in database
now understand this code! sorry
is not exactly what I need because my url is composed of many variables (date,categorie,etc)

I am trying something to post that the article data and redirect me to the same page,
same a comment system (example twitter or other miniblog)

:shock: rss
thanks Bob
GreyHead 19 Aug, 2011
Hi brunotrials ,

I'm sorry I don't know what you do need.

The code posted earlier in this thread should return the user to the same article.

Bob
Newton80 18 Nov, 2011
I think I ran into what the other gentleman did as well. I've added your code (correctly I believe) but the form isn't saving the data. I've got it set up to where a user sees the form as well as the table of data on the same page - not sure if that may be the problem.

Your code will keep the visitor at the same page after submit - perfectly - but its not saving data to the database anymore. I've tried both ways - WITH a URL field and without in the database its writing to and neither way seems to get it to save. Any help would be greatly appreciated.
GreyHead 24 Nov, 2011
Hi Newton80,

Which version of ChronoForms are you using? You can find the version from Site Admin | Extensions | Install/Uninstall | Components in Joomla! 1.5 or Site Admin | Extensions | Extension Manager | Manage in Joomla! 1.6.

This sounds like a run order problem - the redirect is being run before the DB Save.

Bob
This topic is locked and no more replies can be posted.