After the user has inputted their respective username and password, it will be validates and if the submitted information was true, they will redirected a page. Now, I just want to the the php code that captures the username and display it on the page. Like "Welcome BooBoy08 to here..". Please help.

Depends on your look up feature.

But general idea is:

<?
$user=$HTTP_SERVER_VARS["PHP_AUTH_USER"];
?>
Welcome back <b> <?= $user ?>, We have missed you!
<br><br>

It generates errors.

Why don't you put it in a session var??? And then display it with something like echo $var; ?? Don't worry about missing name if this var is empty so the user is not logged in.

When the user logs in, check if he's a valid user. If he's a valid user, add that username to a session variable. Use that session variable in the next page where you want to display his name. A small eg.

<?php //page1.php
session_start();
// check if the user is valid
if (valid user){
$_SESSION['username']=$username;
redirect to page2.php
} else {
 //error message
}

And this is page2.php

<?php
if(isset($_SESSION['username'])){
 echo "Welcome ". $_SESSION['username'];
} else {
  echo "Not logged in ! ";
  exit;
}

Hope that helps.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.