Jump to content

Recommended Posts

guys,

 

i need help. i have a problem with session. it seems that its not working

i have a page that uses session, on the first time you load the page

everything is working fine

i even used print_r to see the session values

but if you refresh the page, its changing the session values with the values of the ones

with the latest id in my database

hope you could help me solve this problem

below is the code for my page

<?
session_start();

if (session_is_registered("username")){
$username = $_SESSION['username'];
$user_level = $_SESSION['user_level'];
print_r($_SESSION);
//$username = $_POST['username'];
include 'db_connect.php';

$query = mysql_query("SELECT userid, username, first_name, last_name, job_title, email, user_level FROM admin_user WHERE username= '$username'") or die(mysql_error()); 
$row = mysql_fetch_array( $query );
$userid = $row["userid"];
$username = $row["username"];
$first_name = $row["first_name"];
$last_name  = $row["last_name"];
$job_title = $row["job_title"];
$email = $row["email"];
$user_level = $row["user_level"];
?>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>:: JobHiRings :: Administration Page</title>
<style type="text/css">
<!--
body {
margin-left: 0px;
margin-top: 10px;
margin-right: 0px;
margin-bottom: 0px;
}
-->
</style>
<link href="css.css" rel="stylesheet" type="text/css">
</head>

<body>
<table width="778" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td colspan="2" background="images/headerbg.gif"><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="226" align="left"><img src="images/header.gif" width="226" height="148"></td>
        <td> </td>
        </tr>
    </table></td>
    <td background="images/headerbg.gif"><img src="images/headeright.gif" width="16" height="148"></td>
  </tr>
  <tr>
    <td width="16" rowspan="2" align="left" valign="top" background="images/left.gif"><img src="images/left.gif" width="16" height="14"></td>
    <td width="745" valign="top"><table width="746" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td colspan="3"> </td>
      </tr>
      <tr>
        <td colspan="3" class="text4">CMS USER MANAGER</td>
      </tr>
      <tr>
        <td colspan="3" align="right"> </td>
        </tr>
      <tr>
        <td colspan="3"><img src="images/spacer.gif" width="10" height="6"></td>
        </tr>
      <tr>
        <td width="224" valign="top"><table width="216" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td colspan="3" valign="top" bgcolor="#3261BB"><img src="images/spacer.gif" width="1" height="1"></td>
            </tr>
          <tr>
            <td align="left" bgcolor="#3261BB" width="1"><img src="images/spacer.gif" width="1" height="1"></td>
            <td width="214" valign="top"><? include 'sidemenu.php'; ?>			</td>
            <td align="right" bgcolor="#3261BB" width="1"><img src="images/spacer.gif" width="1" height="1"></td>
          </tr>
          <tr>
            <td colspan="3" valign="top" bgcolor="#3261BB"><img src="images/spacer.gif" width="1" height="1"></td>
            </tr>
        </table></td>
        <td colspan="2" align="center" valign="top">
          <iframe id="usermngr" src="user/view.php" width=730 height=400 marginwidth=0 marginheight=0 hspace=0 vspace=0 frameborder=0 scrolling=yes></iframe></td>
        </tr>
      

      <tr>
        <td colspan="3"> </td>
      </tr>
    </table></td>
    <td width="16" rowspan="2" align="right" valign="top" background="images/right.gif"><img src="images/spacer.gif" width="1" height="1"><img src="images/right.gif" width="16" height="14"></td>
  </tr>
  <tr>
    <td valign="top"><img src="images/spacer.gif" width="746" height="10"></td>
  </tr>
  <tr>
    <td background="images/footerbg.gif"><img src="images/footerleft.gif" width="16" height="43"></td>
    <td background="images/footerbg.gif"><table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td height="10" colspan="2" align="left"><img src="images/spacer.gif" width="12" height="10"></td>
      </tr>
      <tr>
        <td width="746" align="center" valign="top" class="footer">Copyright © 2007 www.jobhirings.com. All Rights Reserved</td>
      </tr>
    </table></td>
    <td background="images/footerbg.gif"><img src="images/footeright.gif" width="16" height="43"></td>
  </tr>
</table>
<?
}else{
echo "<font face=\"Arial\">You are not authorized to access this page ... Please <a href='index.php'>Login</a></font>";
}
?>

</body>

</html>

Link to comment
https://forums.phpfreaks.com/topic/47581-help-on-_session/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.