Page 1 of 1

Not passing variables

Posted: Tue Aug 14, 2007 11:01 am
by ghadacr
I have a script, based on the button pressed it will forward to a certain page.That bit works fine. What the problem is the variables that are sent are not being passed on to those forwarded pages....

Here is the code:

Code: Select all

<?PHP

//print_r($_GET);

$ClientDetailID = $_GET['ClientDetailID'];
$HotelRoomID = $_GET['HotelRoomID'];
$AvailableFrom  = $_GET['AvailableFrom '];
$AvailableTo = $_GET['AvailableTo'];
$Confirm   = $_GET['Confirm'];
$Release   = $_GET['Release'];
$ResortID   = $_GET['ResortID'];
$status = "OK"; // setting the flag for form validation
$msg=""; // error message string is blank


// Now let us check if name is entered or not
if(strlen($HotelRoomID) < 1 ){ // if name is less than two char length
$msg .="<center>Please select a room</center><BR>";
$status="NOT OK";
}

   if($status<>"OK"){ // if form validation is not passed
echo "<BR><BR>";
echo $msg. "<br><center><input type='button' value='Retry' onClick='history.go(-1)'></center><br><br><br>";


}else{



if ($_GET['Confirm'] > "") {

header('Location: conaddops.php?HotelRoomID='.$HotelRoomID.'&AvailableFrom='.$AvailableFrom.'');

} elseif ($_GET['Release'] > "") {

header('Location: releaseaddops.php?HotelRoomID='.$HotelRoomID.'&AvailableFrom='.$AvailableFrom.'');

}else{

header('Location:flightsearch.php?ResortID='.$ResortID.'&AvailableFrom='.$_GET['AvailableFrom '].'&AvailableTo='.$_GET['AvailableTo'].'&ClientDetailID='.$_GET['ClientDetailID'].'');

}

}
?>

Posted: Tue Aug 14, 2007 11:21 am
by feyd
Verify the $_GET element names are correct.

header() based redirection requires a full URL, http:// and all.

Posted: Tue Aug 14, 2007 11:31 am
by ghadacr
feyd wrote: header() based redirection requires a full URL, http:// and all.
I took out the http part myself for security reasons......

Posted: Tue Aug 14, 2007 11:32 am
by Technocrat
Just as an FYI you should do something like:

Code: Select all

$ClientDetailID = (isset($_GET['ClientDetailID'])) ? $_GET['ClientDetailID'] : '';
That way your not generating a warning.

Also

Code: Select all

if ($_GET['Confirm'] > "") {
Should be:

Code: Select all

if (isset($_GET['Confirm'])) {
Because > "" will generate an empty set warning

Finally though not a problem in this case you should get used to putting either die(); or exit(); after your header locations to stop code below it from executing.

Posted: Tue Aug 14, 2007 11:49 am
by ghadacr
Technocrat-Evo wrote:Just as an FYI you should do something like:

Code: Select all

$ClientDetailID = (isset($_GET['ClientDetailID'])) ? $_GET['ClientDetailID'] : '';
.
I did that and there was no response, but only two of the variables are being passed, and that is

Code: Select all

$ClientDetailID and $HotelRoomID
Which are numbers.. Hmmm not sure???

Posted: Tue Aug 14, 2007 11:53 am
by Technocrat
What is the HTML from the screen that passes this

Posted: Tue Aug 14, 2007 11:59 am
by ghadacr
there is no HTML