Forums

Keep variable after server side validation refresh

quantum_leap 15 Nov, 2012
I am using 2 forms, one is redirecting to the other and the variable $region is also set according to a value of a dropdwn selection. I am appending the variable value in the URL by using this code.
<?php
$option = JRequest::getString('region', '', 'post');
switch ($option) {
  case 'LAM':
  default:
    $url = 'book-training?region=LAM';
    break;
  case 'APAC':
    $url = 'book-training?region=APAC';
    break;
  case 'EMEA':
    $url = 'training-form?region=EMEA';
    break;
   case 'NAM':
    $url = 'book-training?region=NAM';
    break;
}
$url = 'http://mydomain/'.$url;
$mainframe->redirect($url);
?>


On the second form I enquire the variable and use a hidden field
<?php
if ( !$mainframe->isSite()) {return;}
$region = JRequest::getVar('region', '', 'get');
?>
<input type="hidden" name="region" value="<?php echo "$region"; ?>" />

so I can use the variable to my form. After a server side validation occurs, I lose the value of $region. Is there any way I can send the variable back from server side validation or even declare it as global variable somehow?
GreyHead 16 Nov, 2012
Hi quantum_leap,

I assume from your other thread that you are now saving the region to the session.

Bob
quantum_leap 16 Nov, 2012
Yes, thanks for your interest Bob, exactly as you said!
kate_ee 22 Jan, 2014
Is there any solutions?
GreyHead 22 Jan, 2014
Hi kate_ee,

Solutions to what exactly?

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