Re: Strange roblems with sessions
| From: | Kevin Stone | Date: | Wed, 18 Jun 2003 19:40:50 +0000 |
| Subject: | Re: Strange roblems with sessions | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-152052@lists.php.net to get a copy of this message | ||
----- Original Message -----
From: "Logan McKinley" <logan@globalweb.net>
To: <php-general@lists.php.net>; <internals@lists.php.net>
Sent: Wednesday, June 18, 2003 12:51 PM
Subject: [PHP] Strange roblems with sessions
> what it is meant to do:
> take a querystring set it to a session variable (outputs error if neither
> querystring nor sesison exist) then reloads the page (to remove the
> querystring)
> what it (appears) to do:
> it sets the querysting to the session, reloads the page and outputs an
error
> saying it doesn't have the session variable
> if you reload the page with a querystring back in and it works as it is
> meant to
> <------ the code in question -------->
> <?
> session_start();
> if(!isset($_SESSION['HID']) && !isset($_SERVER['QUERY_STRING']))
> die("There was an error registering your product please call techinal
> support at (111)-111-1111");
> else if(!isset($_SESSION['HID']) &&
> isset($_SERVER['QUERY_STRING']))
> {
> $_SESSION['HID'] = $_SERVER['QUERY_STRING'];
> header("Location:
> http://localhost/PHP/registration_form.php");
> }
> ?>
> <--------------------------------->
> I have attached the actual files if that would be of more help,
> Thanks in advance for any help,
> ~Logan
Logan,
When you're activating the script through the browser then
$_SERVER['QUERY_STRING'] is always set. It is only empty or not empty. You
should modify your conditional statements to reflect that..
<?
session_start();
if(!isset($_SESSION['HID']) && empty($_SERVER['QUERY_STRING']))
{
die("There was an error registering your product please call techinal
support at (111)-111-1111");
}
elseif(!isset($_SESSION['HID']) && !empty($_SERVER['QUERY_STRING']))
{
$_SESSION['HID'] = $_SERVER['QUERY_STRING'];
header("Location: http://www.helpelf.com/test2.php");
}
?>
This is tested.
HTH,
Kevin