I've just learnt how to create a simple logging in script.

At the moment the user just logs in and it re-directs you to the home page with no conformation of being logged in.

*I have this header:*
[![enter image description here](https://i.stack.imgur.com/sknn0.png)](https://i.stack.imgur.com/sknn0.png)

Just to the left of the little home icon i would like $username to show of who has logged in.

**index.php** *(which is where that header is)*

```
<table class="header-container">
<tr>
    <td style="width: 40%; text-align: left;"><a href="index.php"><img class="hover-cursor" src="Images/TEAMS_Logo.png"></a></td>
    <td style="width: 10%;" class="custom-header custom-font">TEAMS 
        <span style="color: #cc2020" class="custom-font">W</span><span style="color: #1a488c" class="custom-font">I</span><span style="color: #2a9e56" class="custom-font">K</span><span style="color: #d87f0a" class="custom-font">I </span><span style="font-size: 30px;" class="glyphicon glyphicon-globe"></span></td>
    <td style="width: 40%;">

    <!-- Username to go here -->

        <table style="text-align: right; width: 100%">
            <tr>
                <td style="text-align: right;"><span style="font-size: 24px; text-align: right;" class="hvr-icon-grow"></span></td>
            </tr>
        </table>
    </td>
</tr>

```

*When i click login it runs* **login\_form.php**

```
<?php include 'connectionDetails.php'; ?>

<?php session_start(); ?>

<?php 

if (isset($_POST['username']) and isset($_POST['password'])) 
{
    $username = $_REQUEST['username'];
    $password = $_REQUEST['password'];

    $sql = "SELECT * FROM Users WHERE Username = ? AND Password = ?";

    $user = $username; 
    $pass = $password;

    $stmt = sqlsrv_prepare($conn, $sql, array(&$user, &$pass));

    if( !$stmt ) 
    {
        die( print_r( sqlsrv_errors(), true));
    }   

    sqlsrv_execute($stmt);

    if (sqlsrv_execute($stmt) === true) 
    {
        header('location: index.php');
    }

}

?>

```

So 3 things. 

1) How do i display a username in the header of the index page for the person logged in?

2) What do i add to login\_form.php to bring up an alert box if the credentials entered are incorrect?

3) Is there a way to hide the login button once a user has logged in?