Re: session/header problem (warning:newbie with sessions)

From: Date: Sat, 17 May 2003 18:19:06 +0000
Subject: Re: session/header problem (warning:newbie with sessions)
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-148034@lists.php.net to get a copy of this message
Where are you setting $row inside your if ??? if(mysql_num_rows($result) == 1) { session_start(); $_SESSION['user'] = $row[15]; $_SESSION['pass'] = $row[16]; header("Location:co.details.php"); exit; } looking at the above code you are not defining the $row variable. You need to do something like this. if(mysql_num_rows($result) == 1) { $row = mysql_fetch_row($result); // new line session_start(); $_SESSION['user'] = $row[15]; $_SESSION['pass'] = $row[16]; header("Location:co.details.php"); exit; } this will probably fix the problem. Jim Lucas ----- Original Message ----- From: "Ryan A" <ryan@jumac.com> To: <php-general@lists.php.net> Sent: Saturday, May 17, 2003 9:49 AM Subject: [PHP] session/header problem (warning:newbie with sessions) > Hi, > These are the notices/warnings i am getting and the page exits: > > Notice: Undefined variable: row in > c:\phpdev\www\bwh\co.authenticate.login.php on line 19 > > Notice: Undefined variable: row in > c:\phpdev\www\bwh\co.authenticate.login.php on line 20 > > Warning: Cannot add header information - headers already sent by (output > started at c:\phpdev\www\bwh\co.authenticate.login.php:19) in > c:\phpdev\www\bwh\co.authenticate.login.php on line 21 > > > this is my tiny code: > <?php > error_reporting (E_ALL); > include_once("configbwh.php"); > > $user= $_POST["user"]; > $pass= $_POST["pass"]; > > if(isset($user) && $user && isset($pass) && $pass) > { > $connected=mysql_connect ("$hostt", "$userr", "$passs") or die > ('I cannot > connect to the database because: ' . mysql_error()); > mysql_select_db ("$db"); > > $database["sql"] = " select user,pass from main_co where > user='".$user."' > and pass='".$pass."'"; > > $result = mysql_query($database["sql"]) or die("Error: " . > mysql_error()); > if(mysql_num_rows($result) == 1) > { > session_start(); > $_SESSION['user'] = $row[15]; > $_SESSION['pass'] = $row[16]; > header("Location:co.details.php"); > exit; > } > } > ?> > > what am i doing wrong? > > Kindly reply, > -Ryan > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >

« previous php.general (#148034) next »