Jump to content

Tricky One - Admin Login Problem


KaFF

Recommended Posts

Hi there,

 

im in a bit of a pickle i am trying to display all users in a table on my website with the following code.

The first part looks at the following querys

 

<?php
session_start();
	if( (isset($_SESSION['userid']) =="") && (isset($_SESSION['secretaryid'])=="") && (isset($_SESSION['admin'])=="") ){
}
require "connect.php";
extract($_GET);

if ($_SESSION['userid'] != "") {
$query = "select u.userno,u.userid,u.username,u.role,u.yearid,u.department,s.secname
	from users u, secretary s, usersec us
	where us.secretaryno = s.secretaryno and us.userno = u.userno and u.userid = '".$_SESSION['userid']."'
	order by u.userid, u.yearid";
}
else {
$query = "select u.userno,u.userid,u.username,u.role,u.yearid,u.department,s.secname
	from users u, secretary s, usersec us
	where us.secretaryno = s.secretaryno and us.userno = u.userno
	order by u.userid, u.yearid";
}

$result = @mysql_query($query, $connection)
	or die ("Unable to perform query<br>$query");

?>

 

Then the following code below filters the above query depending on whether the user has logged in as an admin role or standard user.

 

<?php
		while($row=mysql_fetch_array($result))
	{
	if (($row['userid'] == $_SESSION['userid']) || ($_SESSION['admin'] == 1)) {
	?>
	<tr>
		<td style="text-transform: uppercase"><?=$row['userid']?></td>
		<td><?=$row['username']?></td>
		<td><?=$row['role']?></td>
		<td><?=$row['yearid']?></td>
		<td><?=$row['department']?></td>
		<td><?=$row['secname']?></td>
	<?
	if (($_SESSION['admin']) == "1") { ?>
		<td>
		<td width="32" bgcolor="#666666" title="Edit User Details"><a href="updateuserform.php?userno=<?=$row['userno']?>"><font color="#FFFFFF">[edit]</a></td>
		<td width="53" bgcolor="#666666" title="Delete User Details"><a href="deleteuser.php?userno=<?=$row['userno']?>&yearid=<?=$row['yearid']?>" onClick="return confirm('Are you sure you want to delete this User?');">[delete]</a></td>
		<? } ?>
		<?php
		$query2 = "select s.secretaryid, us.yearid from secretary s, usersec us, users u where us.userno = u.userno";
		$result2 = @mysql_query($query2,$connection)
			or die ("Unable to perform query<br>$query2");

		$count=mysql_num_rows($result2);

			if($count <=1){
				echo "*";
				}
			elseif($count >1){
				$row = mysql_fetch_array($result2);
				}
		?>

		<?php }}?>

 

The strange thing is that if a standard user logs in then the information is displayed for that user. But if an admin user logs in it shows nothing.

 

If anyone has any ideas it would really help me as its part of my dissertation that has gotta be in friday! ARGH!

 

Cheers

 

Kaff

Link to comment
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.