Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?php
// First we get the variable we want to look at from the $_GET array
$page = $_GET['p'];
// We should never trust the user's input to be safe
// So let's restrict the possibilities with a switch() statement
// If the input is invalid, we return some sort of error
switch($page) {
case 'home':
// show the home page text
break;
case 'about':
// show the about page text
break;
case 'contact':
// show the contact page text
break;
default:
// none of the above
// show an error
die('Invalid page!');
break;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment