Trying to display the current login user's fullname

Hi…

im just trying to display the current login user’s fullname in the field Current employee name in a file…i did the current user name to be displayed

This is code.


<?php
session_start();
if (isset($_SESSION['id'])){
 $loginid=$_SESSION['id'];
}
if (isset($_SESSION['T_UserName'])){
$T_UserName=$_SESSION['T_UserName'];
}
if (isset($_GET['id'])){
$loginid=$_GET['id'];
//Get  login username if using GET
$loginid=mysql_real_escape_string($loginid);
$query = "SELECT `username` FROM `details` WHERE id=$loginid";
$result = mysql_query($query);
$row = mysql_fetch_row($result);
$T_UserName=$row[0];
}
?>
<?php
if (isset($_SESSION['emp_id'])){
 $loginid=$_SESSION['emp_id'];
}
if (isset($_SESSION['emp_name'])){
$CurrentEmpName=$_SESSION['emp_name'];
}
if (isset($_GET['emp_id'])){
$loginid=$_GET['emp_id'];
//Get  login username if using GET
$loginid=mysql_real_escape_string($loginid);
$query = "SELECT `emp_name` FROM `login` WHERE emp_id=$loginid";
$result = mysql_query($query);
$row = mysql_fetch_row($result);
$CurrentEmpName=$row[0];
}
?>

this is form…


<form action="" method="post" enctype="multipart/form-data" name="employee" target="_self">
   <br />
   <br />
   <table border="1">
   <tr  width="569" colspan="2">
   <td>
     Current User            :
            <input name="CurrentUser" type="text" disabled id="UserId" size="35" maxlength="35" readonly class="disabled"  value="<?php  echo $_SESSION['username'];?>"/>             Activity          :

             <input name="LogActivity" type="text" disabled id="ActLog" size="35" Value="List New Jobs" maxlength="35" readonly class="disabled" />   <br />
       Current Employee Name :

            <input name="CurrentEmpName" type="text" disabled id="CurrentEmpId" size="35" maxlength="35" readonly class="disabled"  value="<?php  echo $_SESSION['emp_name'];?>"/>
   </td>
       </tr>
   </table>

I enjoy singing in the mornings.

Code:
$CurrentEmpName=$_SESSION[‘emp_name’];

Form:
<input name=“CurrentUser” type=“text” disabled id=“UserId” size=“35” maxlength=“35” readonly class=“disabled” value="<?php echo $_SESSION[‘username’];?>

~One of these things is not like the other…~

(PS: You actually want to be using $CurrentEmpName or $T_UserName instead of the session variable in the form anyway. And… why are you retrieving this name twice?)

I got 2 fields in the same form like current user and current Employee name

Now i displayed the current user field by using this code


&lt;?php
session_start();
if (isset($_SESSION['id'])){
 $loginid=$_SESSION['id'];
}
if (isset($_SESSION['T_UserName'])){
$T_UserName=$_SESSION['T_UserName'];
}
if (isset($_GET['id'])){
$loginid=$_GET['id'];
//Get  login username if using GET
$loginid=mysql_real_escape_string($loginid);
$query = "SELECT `username` FROM `details` WHERE id=$loginid";
$result = mysql_query($query);
$row = mysql_fetch_row($result);
$T_UserName=$row[0];
}
?&gt;

and in the same i tried using this code to get the current employee name from another table


&lt;?php
if (isset($_SESSION['emp_id'])){
 $loginid=$_SESSION['emp_id'];
}
if (isset($_SESSION['emp_name'])){
$CurrentEmpName=$_SESSION['emp_name'];
}
if (isset($_GET['emp_id'])){
$loginid=$_GET['emp_id'];
//Get  login username if using GET
$loginid=mysql_real_escape_string($loginid);
$query = "SELECT `emp_name` FROM `login` WHERE emp_id=$loginid";
$result = mysql_query($query);
$row = mysql_fetch_row($result);
$CurrentEmpName=$row[0];
}
?&gt;

K. So your form URL has ?emp_id=<somenumber> attached to the end of it. You then use that value (the session stuff is kinda moot, because you’re probably not actually saving the emp_id or emp_name values to the session anywhere.) You then put the name of the employee into $CurrentEmpName=$row[0]; … so now the name is in $CurrentEmpName . So your form page should use that variable to display the name.

sorry im newbie to php…

<input name=“CurrentEmpName” type=“text” disabled id=“CurrentEmpId” size=“35” maxlength=“35” readonly class=“disabled” value=“<?php echo $CurrentEmpName;?>”/>

im getting this error

Undefined variable: CurrentEmpName in

What does your URL look like?

its a application not a web site