$page = basename($_SERVER['PHP_SELF']); if (!in_array($page, array('page1.php', 'page2.php', 'page3.php', '...'))) { exit('Bad request.'); }