Re: Session variables

From: Date: Tue, 29 Apr 2003 18:16:29 +0000
Subject: Re: Session variables
References: 1 2 3 4 5  Groups: php.windows 
Request: Send a blank email to php-windows+get-19724@lists.php.net to get a copy of this message
It is surpriseing it works the second time i go to the same page after going back to login page and submitting. But gives me an error on the second line on the following code Notice: Undefined index: hostname in e:\INetPub\WWWRoot\phpconverted\scripts\global.inc on line 2 whereas i am setting the value of $_SESSION["hostname"] = "servername"; in the page right before it. <?php $_SESSION["con"]=mssql_connect($_SESSION["hostname"], $_SESSION["user"], $_SESSION["password"]) or die ("Error on connection string."); $_SESSION["dbcon"]=mssql_select_db( $_SESSION["dbname"],$_SESSION["con"]) or die ("database incorrect"); ?> ----- Original Message ----- From: "Stephen" <stephen.edmonds5@btinternet.com> To: "Harpreet" <harpreet@crispincorp.com> Cc: "Windows Helplist (PHP)" <php-windows@lists.php.net> Sent: Tuesday, April 29, 2003 1:11 PM Subject: Re: [PHP-WIN] Session variables > Um looks to me like you are starting a session variable without any > values... I do not think that is acutally possible hense the error message > you got. session_register() is not supposed to be used in php 4.3.0>, I > would stick with using $_SESSION[] = as you have done on the second script > > ----- Original Message ----- > From: "Harpreet" <harpreet@crispincorp.com> > To: <php-windows@lists.php.net> > Sent: Tuesday, April 29, 2003 5:34 PM > Subject: [PHP-WIN] Session variables > > > > I am having an issue with session variables. I define my variables in > > global.inc file. When i use the variables in a page callled traffic.php > file > > i get the following error. > > > > Notice: Undefined index: user in > > e:\INetPub\WWWRoot\phpconverted\scripts\global.inc on line 2 > > > > But if i press the back button and go again to the traffic page I can > login > > fine. > > > > Where am i going wrong. > > > > my global1.inc file code is as follows > > <?php session_start(); > > session_register("user"); > > ?> > > > > login.php file code: > > <?php > > $_SESSION["user"]=$HTTP_POST_VARS["user"]; > > if ($con="Resource id #1") > > { header("Location: traffic.php"); > > exit(); > > } > > else > > { > > header("Location: ../notlogged.htm"); > > exit; > > } > > ?> > > > > > > > > > > -- > > PHP Windows Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > > > -- > PHP Windows Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php >

« previous php.windows (#19724) next »