Simple case statement question

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
mhouldridge
Forum Contributor
Posts: 267
Joined: Wed Jan 26, 2005 5:13 am

Simple case statement question

Post by mhouldridge »

Hi,

I have the following case statement which checks the user level variable as follows;

Code: Select all

switch ($i) {
	case "1":
   	header("Location: http://www.somewhere.com");
   	break;
	case "2":
  	header("Location: http://www.somewhere.com");
  	break;
	case "3":
   	// User allowed
   	break;
	}
I would like case 3 to give the user access without outputting anything. Will this automatically let them in, or do I need some code to do something. I know this sounds like a stupid question but I cant quite get my head round what to do here.

All I want is for case 3 to allow the user to access the page that the code is on.


thanks
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Post by shiznatix »

well 1st of all, after your header() make sure you do die(); before the break. if this code is on the same page the switch statement is on then just leave out the case "3" part and let the code execute.
User avatar
mhouldridge
Forum Contributor
Posts: 267
Joined: Wed Jan 26, 2005 5:13 am

Post by mhouldridge »

Sorted!, Thanks for this,

Everything is working correctly now.
Post Reply