0

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.

4
Contributors
4
Replies
5
Views
9 Years
Discussion Span
Last Post by nav33n
0

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>
0

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.

0

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.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.