Jump to content

swith problem


182x

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.