Jump to content

Recommended Posts

Hey guys,

 

I am using the code below in order to log a user in and then based on their accesss level theres user id is stored as a session variable. That variable is then is checked when their redirected page loads to ensure they can have access and its not just a user typing in the url.

 

However when i login as user two it can then access teh user 1 account by typing in the url.

 

I was just wondering what I have done wrong?

 

Thanks.

 


switch($user)
{

	case 1:

		$Id = "SELECT uId FROM u WHERE u = '$u' AND p= '$p";
		$qu= mysql_query($Id, $link);

		if (mysql_num_rows($qu) > 0 )
			{
				$st= mysql_fetch_assoc($qu);
				$_SESSION ["userId"] = $st["userId"];
				header("location:test.php");
				exit();
			}
			break;

	case 2: 

		$Id = "SELECT uId FROM u WHERE u = '$u' AND p = '$p'";
		$query = mysql_query($getId, $link);

		if (mysql_num_rows($query) > 0 )
			{
				$st2= mysql_fetch_assoc($qu);
				$_SESSION ["userId"] = $storeEmployee["userId"];
				header("location:test2.php");
				exit();
			}

	break;

 

 

Link to comment
https://forums.phpfreaks.com/topic/59743-swith-problem/
Share on other sites

I'd suggest that you look at the login script itself. perhaps post that code... I wonder whether echoing the $user variable before you make the switch statement might be any use... then you can check that you got to this point with no problem...

Link to comment
https://forums.phpfreaks.com/topic/59743-swith-problem/#findComment-297130
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.