How to Fetch Logged in Username

 

after login, we need to fetch the Username. We will explain How to Fetch Logged in the Username.

index.php

<?php
include("db.php");
session_start();
if($_SESSION['username']=="")
{
session_destroy();
header("location:index.php");
}
?>
<html>
<head>
<title>Fetch Loged in Username</title>
</head>
</body>
	       <?php
		   include('db.php'); 
	$query="select * from user where username='".$_SESSION['username']."' ";
	$query1=mysql_query($query);
	$row=mysql_fetch_array($query1)
	?>

<h1>            <?php echo $row['name']; ?></h1>
</body>
</html>

db.php

<?php 
mysql_connect('localhost','root','');
mysql_select_db('database');
?>

Comments

Popular posts from this blog

Student Result Management System

What Is The Job Role Of A Customer Support Executive?

TOP RECRUITMENT COMPANIES IN INDIA