Hello i want 2add the name of the person who logged in at the top of the page, but the name comes from a SQL database called details, but the username and password is kept in another table called member they both are linked by id, this code below luks 2be right but it dont display the name 4 some reason can anybody help thanks

You are logged in as <?php echo $_SESSION; ?>. To log out <a href="homepage.html">click here</a>.

You need a database query on your login page to fetch the name you wish to display, then to register it in $_SESSION. Not possible to show you exactly how without seeing your login page code.

Matti Ressler

hello mate which login page? the 1 u fill the username and password or the code that links 2database

The code that links to database when you login.

Matti Ressler

$host="host"; // Host name 
$username="dk"; // Mysql username 
$password="d"; // Mysql password 
$db_name=""; // Database name 

// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
mysql_select_db("$db_name")or die("cannot select DB");

// username and password sent from form 

// encrypt password 

// To protect MySQL injection (more detail about MySQL injection)
$myusername = stripslashes($myusername);
$mypassword = stripslashes($mypassword);
$myusername = mysql_real_escape_string($myusername);
$mypassword = mysql_real_escape_string($mypassword);

$sql="SELECT * FROM members WHERE username='$myusername' and password='$encrypted_mypassword'";

// Mysql_num_row is counting table row
// If result matched $myusername and $mypassword, table row must be 1 row

// Register $myusername, $mypassword and redirect to file "login_success.php"
else {
echo "Wrong Username or Password";

Try this:

// Register $myusername and redirect to file "login_success.php"
$_SESSION['myusername'] = $myusername; 

I dont see any reason to register the password.

You did mention using name from the other table - you can retrieve that based on id from $result and register it the same way.

Also, you should be sanitizing the user input before using it in database queries.

Matti Ressler