How do I setup the redirect page based on user's selection ?

In this article we will present 2 methods to redirect your user upon completing the form, based on the data he submitted.

 
Method 1 - Using the Return URL feature

For this method, scripting knowledge is not needed.Let's assume that your radio group form component is named "radio". The items of this form component will have to look similar to this:

  • http://www.your_site.com/cycling|Cycling
  • http://www.your_site.com/motorsports|Motor sports
  • http://www.your_site.com/parkour|Parkour

In the "Form Info" tab, just fill in the "Return URL" option with the following syntax:

{radio:value}

 

Your form's specific placeholders can be viewed by clicking on the "Toggle Quick Add" button, found in the upper-right corner (see picture).

Explanation:
  • The "|" pipeline symbol is being used to split the value from the label of the radio group item.
  • In the frontend, the radio group options will only show the text after the pipeline (in this case hobbies and not the URLs). The actual value of the placeholder inherits the text before the pipeline.
  • The {radio:value} will be replaced with an URL.
Note:
  • There is also a placeholder available for the right part of the pipeline, the label itself. The syntax for this radio group would be {radio:text}.
 
Method 2 - Using the PHP scripts area

The second method would be to create a custom PHP script, that will check the value of your field and redirect accordingly.

Assuming your radio group is named "radio" and the items as follows:

  • 1|Cycling
  • 2|Motor Sports
  • 3|Parkour
 

By using the code below in the Scripts called after form has been processed, the user will be redirected after he submits the form

 
    if($_POST['form']['radio'] == '1'){
      $mainframe->redirect("http://cyclingsite.com");
      }else if($_POST['form']['radio'] == '2'){
        $mainframe->redirect("http://motorsportsite.com");
        }else if($_POST['form']['radio'] == '3'){
          $mainframe->redirect("http://parkoursite.com");
          }
 

If you are using dropdown elements instead of radio groups, remember to add the [0] index to the post variable (e.g. $_POST['form']['dropdown'][0] )


18 persons found this article helpful.


Was this article helpful?

Yes No
Sorry about that