Ok so I have a login page which actually gets an employees ID and password and includes the employee id and surname+firstname in a session. Now in the following page:

<?php
  require_once("nocache.php");

  session_start();

  if (!$_SESSION["who"])
   {
    header("location: logoff.php");
    }
  else 
   {
    $emp = $_SESSION["who"];
    $sn=$_SESSION["surname"];
    $fn=$_SESSION["firstname"];
   }
require_once("dbconn.php");

$sql="SELECT reviewYear,datecompleted,completed FROM reviews WHERE reviews.empid='$emp'";

$rs = mysql_query($sql, $dbConn);

?>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>
  <title> Review</title>
</head>
<body>
<h1>Review Page</h1>
<p>


<h3>Welcome to the Review Page <?php echo $fn;?> <?php echo $sn;?>  (<?php echo $emp; ?>)</h3>

<?php
while ($row = mysql_fetch_array($rs)) { ?>

<h4>Date Completed:</h4>
<?php echo $row["datecompleted"]?>
<h4>Review Year</h4>
<?php echo $row["reviewYear"]?>
<h4>Completed</h4>
<?php echo $row["completed"]?>

<?php }; ?>
<br/>
<a href="logoff.php">Log Off</a><br/> 

</p>

</body>

</html>

Im trying to get the page to show the details i.ereviewYear,datecompleted,completed from the reviews table for the logged in user.I tried doing an sql statement,but i doesnt work.Could someone please help me out?:(

Member Avatar for rajarajan2017

Echo your $emp, so that you will know whether you get the value of empid or not?

I just thought of doing that too.Let me see and let u know

I did echo the $emp.Even in the above code.On line 37, ive echoed the emp.But i still dont get the values i want!:S

Member Avatar for rajarajan2017

check whether the sessions are properly retrieved and the result echoed by $emp r8?

Yep i checked it.When i call the variables in line 37 i check that they've been retrieved.

Hey i got it working!!It was a simple mistake!!Thanks!:)

Great !!

Maybe you can post here what went wrong with the script so others can refer to it, if needed

Suggestions :
1. put session_start() on top (before require_once("nocache.php")) cause if nocache.php sends any header, the script will not work.
2. Just after ' $emp = $_SESSION["who"]; ' write echo $emp;
3. Let me know if you are able to print the value of $emp.

Yep i got it done.It does echo the $emp cuz i used it in line 37 to Welcome the employee that is logged in.Thanks!:)

Great !
Please close this post as Solved :)

Thanks
Vivi
First, solve the problem. Then, write the code.

Uhh Could you please tell me how to do that?:|

Ok got it done!

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.