here if user logged information is correct it should show the main page. in that mainpage right top corner i need to show the username, employee id, employee name. here i can get username correctly. but, i did not get employee id and employee name.
for example : Name - Indian, Username - Indian1990, Emp id - EMP_6504 these all values already stored in database using registration form. now they logged in using Username - Indian1990 and Password - 123456. and then mainpage will open. In that page i need to show EMPLOYEED ID and NAME of the Username - Indian1990. how to fetch the exact details of username in mainpage????
login page php coding :
<?php
session_start();
if($_SERVER['REQUEST_METHOD'] == "POST")
{
$uname = $_POST['username'];
$pwd = $_POST['password'];
$uname = htmlspecialchars($uname);
$pwd = htmlspecialchars($pwd);
include("config.php");
if (!$_POST["username"] || !$_POST["password"])
{
echo "You need to provide a username and password.";
}
$result = mysql_query( "SELECT * FROM emp_register WHERE emp_username = '$uname' AND emp_password = '$pwd'" );
while($row = mysql_fetch_array($result))
{
if($row["emp_username"] == $uname && $row["emp_password"] == $pwd)
{
// Login good, create session variables
$_SESSION["valid_id"] = $row->id;
$_SESSION["valid_user"] = $_POST["username"];
header ('Location: mainpage.php');
}
else
{
echo "Sorry, could not log you in. Wrong login information.";
}
}
}
?>
mainpage php coding :
before html tag :
<?php
session_start();
if (!$_SESSION["valid_user"])
{
// User not logged in, redirect to login page
header("Location: login.php");
}
?>
inside html tag :
<td width="182" rowspan="5" valign="top">
<?php
echo "<p class=bluetext>Employee ID : " . $_SESSION["valid_id"];
echo "<p class=bluetext>Username : " . $_SESSION["valid_user"];
// Display logout link
echo "<p class=outtext><a href=\"logout.php\">Logout</a></p>";
?>
</td>