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.