• 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: want redirect upon submission *only* if form valid

want redirect upon submission *only* if form valid 11 years 8 months ago #24492

  • register
  • register's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 4
I added a PHP script to redirect the form upon submission.

However, I only want the redirect to happen if the submission is valid. If required fields have not been filled in, I want the user to stay there, and complete the form properly.

How can I do this? Here is my (redacted) script:

$theID = JRequest::getVar('id');
header('Location:http://server.com/index.php?option=com_content&view=article&id=' . $theID . '');
die();
The administrator has disabled public write access.

want redirect upon submission *only* if form valid 11 years 8 months ago #24499

  • register
  • register's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 4
Problem solved - I had the PHP code in the wrong box. I had it in "Script called on form process" instead of "Script called after form has been processed".


On an unrelated note - perhaps this will help someone else: In some scenarios, the URL variable can go away. Need to store them in the session.

Something like:

$theID = JRequest::getVar('id','error');
if ($theID != 'error') {
$_SESSION = $theID;
} else {
if(isset($_SESSION) && !empty($_SESSION)) {
$theID = $_SESSION;
}
}

Then later to use it:

if(isset($_SESSION) && !empty($_SESSION)) {
$theID = $_SESSION;
} else {
$theID = 0;
}
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!