phpSensei Posted August 1, 2007 Share Posted August 1, 2007 This is my index page for my site... <?php $action=$_GET['page']; switch($action){ case '': index(); break; case 'view_comments': echo "here be comments"; break; } ?> My issue is that when ever a user enters something like this www.localhost.com/?page=dssdasdasdasd, As you can see the "asasasas" is a random string which doesnt exist in my switch statement.... HOW can I show an error message for whenever the page doesnt exists? Please try to understand. Link to comment https://forums.phpfreaks.com/topic/62931-using-the-switch-statement-issue/ Share on other sites More sharing options...
GingerRobot Posted August 1, 2007 Share Posted August 1, 2007 Add a default case: <?php $action=$_GET['page']; switch($action){ case '': index(); break; case 'view_comments': echo "here be comments"; break; default: echo 'Invalid action'; break; } ?> Link to comment https://forums.phpfreaks.com/topic/62931-using-the-switch-statement-issue/#findComment-313353 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.