hi n working with a code but m facing a problem of undefined index. i have seen it occurs due to unavailablity of data or like that but here i m declaring that data jst before its use. rest of variable are working correctly just SESS_dept is giving error plz can you] tel why?

$employee = mysql_fetch_assoc($result);
      $_SESSION['SESS_EMP_ID'] = $employee['employee_id'];
      $_SESSION['SESS_NAME'] = $employee['employee_name'];
	  $_SESSION['SESS__dept']=$employee['department_name'];
	  $_SESSION['SESS_rank']=$employee['rank'];
      
      session_write_close();
	  if 
	  ($_SESSION['SESS_rank']=="admin")
	  {
      header("location: administrator.php");
      exit();
	  }
	  
	  elseif ($_SESSION['SESS_dept']=="molding")
     	 {
			if($_SESSION['SESS_rank']=="shift incharge")
	  		{
	  		header ("location: Shift_incharge.php");
	  
	 	 	exit();
	  		}

Recommended Answers

All 3 Replies

You have a syntax error in your code. First you declare this:

$_SESSION['SESS__dept']=$employee['department_name'];//error here, remove one underscore from the SESS__dept

But then you use this:

elseif ($_SESSION['SESS_dept']=="molding")

Your SESS_dept has two underscores ('_ _') when you initialize it.

Just remove one underscore from the first one.

thnx its solved. but now my page is not redirecting to any where it jst show blank page

Is that your entire code for the script?

If it is, you're missing a closing key '}' at the end

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.