Not passing variables

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
ghadacr
Forum Contributor
Posts: 135
Joined: Fri May 11, 2007 10:44 am

Not passing variables

Post 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'].'');

}

}
?>
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Verify the $_GET element names are correct.

header() based redirection requires a full URL, http:// and all.
User avatar
ghadacr
Forum Contributor
Posts: 135
Joined: Fri May 11, 2007 10:44 am

Post by ghadacr »

feyd wrote: header() based redirection requires a full URL, http:// and all.
I took out the http part myself for security reasons......
User avatar
Technocrat
Forum Contributor
Posts: 127
Joined: Thu Oct 20, 2005 7:01 pm

Post 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.
User avatar
ghadacr
Forum Contributor
Posts: 135
Joined: Fri May 11, 2007 10:44 am

Post 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???
User avatar
Technocrat
Forum Contributor
Posts: 127
Joined: Thu Oct 20, 2005 7:01 pm

Post by Technocrat »

What is the HTML from the screen that passes this
User avatar
ghadacr
Forum Contributor
Posts: 135
Joined: Fri May 11, 2007 10:44 am

Post by ghadacr »

there is no HTML
Post Reply