• 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!

TOPIC: 2 Return URL

2 Return URL 1 week 4 days ago #43907

  • info9374
  • info9374's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 3
Hello,

I have a quiz with one question and 4 answers. If the answer is correct, Forms should redirect to /success if the answer is wrong to /sorry. How can I implement 2 different redirects depending on the value?
The administrator has disabled public write access.

2 Return URL 1 week 3 days ago #43908

  • iceferret
  • iceferret's Avatar
  • OFFLINE
  • Gold Boarder
  • Posts: 245
  • Thank you received: 64
We can do that with a couple of php scripts. to try this out I created a form with two fields, a text field 'question' (what is 2 x 2?)and a dropdown 'answer' (3,6.4.8,32)
If they get the answer correct we can use the default Rsform thank you page with a custom message like CORRECT! in a big font, for the sorry create a joomla article witf for example WRONG! in a big font, create a hidden menu link to this article and copy the url somewhere.
In sripts called on form process put this
$correctAnswer = 4;
$userAnswer = $_POST['form']['answer'][0];
 
if ($userAnswer == $correctAnswer) {
    return true; // Proceed to the default thank you page
} else {
    // Store the redirect URL in a session variable
    $session = JFactory::getSession();
    $session->set('redirect_url', 'index.php?option=com_content&view=article&id=1154'); //add your particular url in place of this one
 
    return true; // Let RSForm continue processing
}

Now in script called after form processed add
$session = JFactory::getSession();
$redirectUrl = $session->get('redirect_url', '');
 
if (!empty($redirectUrl)) {
    $session->clear('redirect_url'); // Clear session to avoid future redirects
    JFactory::getApplication()->redirect($redirectUrl);
}

You shouls find that does the trick, you might want add a return to previous page button in the 'sorry' article too
If you can keep your head when all about you are losing theirs, then you obviously don't understand the situation!
Last Edit: 1 week 3 days ago by iceferret.
The administrator has disabled public write access.
  • 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!