At 04:02 21.11.2002, Stephen said: --------------------[snip]-------------------- >I have a PHP script that logs someone in then takes them to another page >indicating their online status. However, when I try echoing out the >contents of the session variable, it says this: > > Notice: Undefined variable: _SESSION in c:\program files\apache > group\apache\htdocs\checker\members\index.php on line 38 > >Here's the code that registers the variable, or is atleast supposed to: > > if ($dbconn) { > $querystr = "SELECT user FROM users WHERE (user = '" . > prepareData($_POST['user']) . "' and pass=PASSWORD('" . > prepareData($_POST['pass']) . "'))"; > $result = mysql_query($querystr,$dbconn); > if ($result) { > if ($frow = mysql_fetch_row($result)) { > session_start(); > session_register('user'); > $_SESSION['user'] = $frow[0]; > header("Location: index.php?" . SID); > exit(); > } > else { > $error = "Invalid username and password combo."; > } > } > >Here's where I echo it out: > > <div align="left" class="log"><font size="2">Logged in as <?php echo > $_SESSION['user']; ?></font></div> --------------------[snip]--------------------
What's line 38 - is it the line where you assign to it, or is it the line with the echo? If it's the line with the assignment - duh, this should work IMHO if it's the line with the echo - you got nothing from mysql and didn't start the session. BTW - you shouldn't mix session_register() and accessing the $_SESSION array. Definetely it's not needed. -- >O Ernest E. Vogelsinger (\) ICQ #13394035 ^ http://www.vogelsinger.at/