SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Enthusiast
    Join Date
    Feb 2012
    Posts
    39
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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.
    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..
    Code:
    <form action="" method="post" enctype="multipart/form-data" name="employee" target="_self">
       <br />
       <br />
       <table border="1">
       <tr  width="569" colspan="2">
       <td>
       &nbsp;&nbsp;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" />&emsp;&nbsp;&nbsp;<br />
         &nbsp;&nbsp;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>

  2. #2
    Keeper of the SFL StarLion's Avatar
    Join Date
    Feb 2006
    Location
    Atlanta, GA, USA
    Posts
    3,748
    Mentioned
    69 Post(s)
    Tagged
    0 Thread(s)
    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?)
    Never grow up. The instant you do, you lose all ability to imagine great things, for fear of reality crashing in.

  3. #3
    SitePoint Enthusiast
    Join Date
    Feb 2012
    Posts
    39
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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

    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];
    }
    ?>
    and in the same i tried using this code to get the current employee name from another table

    Code:
    <?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];
    }
    ?>

  4. #4
    Keeper of the SFL StarLion's Avatar
    Join Date
    Feb 2006
    Location
    Atlanta, GA, USA
    Posts
    3,748
    Mentioned
    69 Post(s)
    Tagged
    0 Thread(s)
    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.
    Never grow up. The instant you do, you lose all ability to imagine great things, for fear of reality crashing in.

  5. #5
    SitePoint Enthusiast
    Join Date
    Feb 2012
    Posts
    39
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    sorry im newbie to php...

  6. #6
    Keeper of the SFL StarLion's Avatar
    Join Date
    Feb 2006
    Location
    Atlanta, GA, USA
    Posts
    3,748
    Mentioned
    69 Post(s)
    Tagged
    0 Thread(s)
    <input name="CurrentEmpName" type="text" disabled id="CurrentEmpId" size="35" maxlength="35" readonly class="disabled" value="<?php echo $CurrentEmpName;?>"/>
    Never grow up. The instant you do, you lose all ability to imagine great things, for fear of reality crashing in.

  7. #7
    SitePoint Enthusiast
    Join Date
    Feb 2012
    Posts
    39
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    im getting this error

    Undefined variable: CurrentEmpName in

  8. #8
    Keeper of the SFL StarLion's Avatar
    Join Date
    Feb 2006
    Location
    Atlanta, GA, USA
    Posts
    3,748
    Mentioned
    69 Post(s)
    Tagged
    0 Thread(s)
    What does your URL look like?
    Never grow up. The instant you do, you lose all ability to imagine great things, for fear of reality crashing in.

  9. #9
    SitePoint Enthusiast
    Join Date
    Feb 2012
    Posts
    39
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    its a application not a web site


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •