Jump to content


This topic is now archived and is closed to further replies.


problems showing a database entry

Recommended Posts

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.



// start the session


// 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


// 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");







// 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>";} 



if (!isset($username)) 

{ echo "<center>Either you have not registered or your username and or password is incorrect."; } 


{ echo "<center>You are not logged in. <br>"; } 

echo "<center><a href="index.php">Login</a><br>"; } 




Share this post

Link to post
Share on other sites


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.