That worked! Thank you everyone! Jer
--- In [email protected], "Mike" <[EMAIL PROTECTED]> wrote: > > no - you will still need the session_start(); call - it's just that they have > deprecated session_register, so it's best to not use it now so you don't have to rewrite code later. > > Once you know the user is logged in, then do this line to assign the value to > a session variable. > > $_SESSION["valid_user"] = $name["username"]; > > Then to get the user name later, do > > print '<span class="header">Welcome back, > '.$_SESSION["valid_user"].'!</span>'; > > > ----- Original Message ----- > From: Jer > To: [email protected] > Sent: Wednesday, September 13, 2006 3:20 PM > Subject: [php_mysql] Re: User authentication woes > > > So, does $_SESSION replace both session_register() and session_start()? > > --- In [email protected], "Mike" <mike@> wrote: > > > > Also note - from > http://us2.php.net/manual/en/function.session-register.php > > > > instead of session_register - the use of $_SESSION is preferred, as of > PHP 4.1.0 > > > > $_SESSION["valid_user"] = $name["username"]; > > > > If your script uses session_register(), it will not work in environments > where the PHP > directive register_globals is disabled. Since PHP 4.2.0, the default value > for the PHP > directive register_globals is off, and it is completely removed as of PHP > 6.0.0. > > > > ----- Original Message ----- > > From: Jer > > To: [email protected] > > Sent: Wednesday, September 13, 2006 2:34 PM > > Subject: [php_mysql] User authentication woes > > > > > > Can someone tell what I'm doing wrong? I get an error at the > session_start and it > doesn't > > register the user name in a cookie. > > > > Thanks, > > > > Jer > > > > session_start(); > > > > if ($userid && $password) > > { > > // if the user has just tried to log in > > > > mysql_connect('localhost', 'xx', 'xx'); > > mysql_select_db('xx'); > > > > $query = "SELECT * FROM users > > WHERE username = '$userid' AND password = '$password'"; > > $result = mysql_query($query) or die(mysql_error()); > > $rows = mysql_num_rows($result); > > > > if (0<>$rows) > > { > > // if they are in the database register the user id > > > > while ($name = mysql_fetch_array($result)) > > { > > $valid_user = $name["username"]; > > session_register("$valid_user"); > > > > print '<span class="header">Welcome back, '.$name["username"].'!</span>'; > > } > > > > } > > else > > { > > print '<span class="header">You could not be logged in. Please try again > or > register.</ > > span>'; > > } > > } > > > > > > > > > > > > [Non-text portions of this message have been removed] > > > > > > > > [Non-text portions of this message have been removed] > The php_mysql group is dedicated to learn more about the PHP/MySQL web database possibilities through group learning. Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/php_mysql/ <*> Your email settings: Individual Email | Traditional <*> To change settings online go to: http://groups.yahoo.com/group/php_mysql/join (Yahoo! ID required) <*> To change settings via email: mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/
