Skip to content Skip to sidebar Skip to footer

Display Username Once User Has Logged In

Hello i am try to display the username after they log in. here is my code This is the page i would like to show it. index.php

Solution 1:

In your index.php write the following code:

<div id="top-register">
<?
echo "Hello" .$_SESSION['username'];
?>

Solution 2:

Create a session variable which will save the username you got from the query then echo that session variable in your page.


Solution 3:

I think, you missed the echo before. Change

<?
$_SESSION['username']
?>

to

<?
echo $_SESSION['username']
?>

Solution 4:

In class Membership change this...

    if($ensure_credentials) {
        $_SESSION['status'] = 'authorized';
        header("location: index.php");
    } else return "Please enter a correct username and password";

To this...

   if($ensure_credentials) {
        $_SESSION['status'] = 'authorized';
        $_SESSION['username'] = $un;
        header("location: index.php");
    } else return "Please enter a correct username and password";

Solution 5:

I used the same nettuts tutorial for my user login page. This is what works for me to show logged in user on index.php page.

INSERT IN BODY OF INDEX.PHP PAGE:

<?php
echo "Welcome ", $_SESSION['username'];
?>

Post a Comment for "Display Username Once User Has Logged In"