siphi Posted December 18, 2003 Share Posted December 18, 2003 Hi I\'m trying to get the users email address to be shown on the login page when he logs in. But it\'s not working. I\'m also trying to put it into a session. Heres the code. <?php // start the session session_start(); // checks if userid and pwd are entered in form if ($username && $password) { // connects to the database $Connect = mysql_connect("localhost", "root", "password"); // selects the database user mysql_select_db("database"); // selects all from database user where userid equals form entry uid and password equals form entry pwd $sql = " SELECT * FROM user WHERE username = \'$username\' AND password = PASSWORD(\'$password\')"; $result = mysql_query($sql); // checks user exists if (mysql_num_rows($result) > 0) { while($row = mysql_fetch_array($result)) {$row[email] = $email;} // sets up variables $valid_user = $username; $password = $password; // registers variables into session session_register("valid_user, password, email"); } } ?> <?php // checks that valid_user and password are registered if (session_is_registered("valid_user, password, email")) { $_SESSION[\'valid_user\'] = $_POST[\'username\']; $_SESSION[\'password\'] = $_POST[\'password\']; echo "<center><br><br>You are logged in: $valid_user <br>Your password: $password <br>Your email: $email<br>"; echo "<center><a href="index.php?c=11">Continue to members area</a><br>"; echo "<center><a href="testsetings.php">Change your password</a><br>"; echo "<center><a href="logout.php">Log out</a><br>";} else { if (!isset($username)) { echo "<center>Either you have not registered or your username and or password is incorrect."; } else { echo "<center>You are not logged in. <br>"; } echo "<center><a href="index.php">Login</a><br>"; } ?> Thanks. Quote Link to comment Share on other sites More sharing options...
shivabharat Posted December 18, 2003 Share Posted December 18, 2003 Never mix $_SESSION and session_register() http://www.phpfreaks.com/forums/viewtopic.php?t=10842 See this link http://www.phpfreaks.com/forums/viewtopic.php?t=7632 Also there are lot of posting available about sessions have a look at them. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.