phpdragon Posted February 8, 2009 Share Posted February 8, 2009 I am trying to figure out how to do this, could someone tell me how to perform a function that would do something similar to the following. <?php if (($_SESSION["type"] != 'admin') OR ($_SESSION["type"] != 'reseller')) { header("Location: login_error.php"); } ?> //// rest page here if session type does equal either of above Link to comment https://forums.phpfreaks.com/topic/144276-solved-how-to-use-if-to-check-var-is-this-or-that/ Share on other sites More sharing options...
peranha Posted February 8, 2009 Share Posted February 8, 2009 if (($_SESSION["type"] != 'admin') || ($_SESSION["type"] != 'reseller')) That says if ((session type does not equal admin) or (session type does not equal reseller)) if (($_SESSION["type"] == 'admin') || ($_SESSION["type"] == 'reseller')) That says if ((session type is equal to admin) or (session type is equal to reseller)) Link to comment https://forums.phpfreaks.com/topic/144276-solved-how-to-use-if-to-check-var-is-this-or-that/#findComment-757139 Share on other sites More sharing options...
printf Posted February 8, 2009 Share Posted February 8, 2009 Maybe in_array() <?php if ( ! in_array ( $_SESSION['type'], array ( 'admin', 'reseller' ) ) ) { header ( 'Location: login_error.php' ); exit (); } ?> Link to comment https://forums.phpfreaks.com/topic/144276-solved-how-to-use-if-to-check-var-is-this-or-that/#findComment-757140 Share on other sites More sharing options...
phpdragon Posted February 8, 2009 Author Share Posted February 8, 2009 Thank you printf the in_array option works a treat. Link to comment https://forums.phpfreaks.com/topic/144276-solved-how-to-use-if-to-check-var-is-this-or-that/#findComment-757149 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.