Double redirect after submitting a form

Barcellos

Ana Barcellos
Hi, guys! :) Please some good soul to help me with this?

When I submit a form I need to:
  • Redirect to one specific page AND
  • Download one file depending on the option selected in one of the elements
I found a solution but it works in my development website but not in the production one. Since I am running different Fabrik versions I thought maybe I'm having a syntax issue.

1) Development
Joomla 3.4.8
Fabrik 3.1.1
PHP 5.3

I used the redirect plugin in the form, redirecting to a php file and passing my javascript code by this file.
- append data to jump url = yes

I'm getting the url to redirect adding them in the values of the options of a dropdown element.

Then I am getting the variables on php file like this:

PHP:
<?php
     {
         $url = $_GET["table_name___element_name"];
               { echo "<script>window.open('$url');</script>";
                     }
               { echo "<script>window.location = 'http://www.xxx.com';</script>";
                     }
    }
?>

It works perfectly!

2) Production
Joomla 3.4.8
Fabrik 3.4.2
PHP 5.4

Here the first part of the code doesn't work. It just redirect in the same page but doesnt open the new tab.

Any clue why?
 
Instead of the redirect plugin and javascript, did you try using just the form PHP plugin instead?
Write the if conditions for the php code that needs to be done, including the redirects, and put it in 'End of form submission (onAfterProcess)'.
 
[...]
Bauer, I tried to use php plugin but for some reason the javascript was not running from there. Not sure why. :/ Thanks,
I must be missing 'the big picture' for what you are trying to do. I saw no need to use javascript to begin with. What am I missing? Why can't both the file download and any subsequent redirect be done via some post-processing php code?

Using just the form php plugin, if it's just a matter of 2 different possible redirect urls, then initialize the 2 urls and any message or message type arguments for the redirect function - then assign the appropriate url and redirect. E.g...

$url = $data['table___element'] ? $url1 : $url2 ;
$app = JFactory::getApplication();
$app->redirect( $url, $msg='', $msgType='message' );
 
[...] Why can't both the file download and any subsequent redirect be done via some post-processing php code? [...]

Simple answer to myself: because I am not a developer and I went the further that I could with Master Google's support. :D

Thank you very much for giving me this new direction. I will try that way.
 
Maybe I misread what you are trying to do:

  • Redirect to one specific page AND
  • Download one file depending on the option selected in one of the elements
... which I read as you always want to redirect, but if an element has a certain value, you want to download a file as well.

-- hugh
 
Hugh, I want to redirect to one page (always the same) AND download a file at the same time.
But the file to be downloaded will depend on the option selected by the user in the form.
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top