I know the code above is too advance for someone who is a beginner but here is a simply code. The code is mostly self explanatory.
CODE
<?php
if ( isset( $_GET['page'] ) ){
$page = $_GET['page']; # Getting page ID ex. ?page=2
}
if ( empty( $page ) || $page == '' || $page == '0' ){
echo "Home Page Content";
} else if ( $page == '1' ){
echo "Page 1 Content Goes Here";
} else if ( $page == '2' ){
echo "Page 2 Content Goes Here";
} else {
echo "Page Not Found";
}
?>
Within the code their are for pages:
- Homepage
- Page 1
- Page 2
- Error Page
To access the
Homepage you simply can access it by going to the
page.php, or page.php?page=0To access page one and to you can go to
page.php?page=1 or page.php?page=2To acess the error page you can go to any page that is not listed ex. 3, 4, 5, etc.
To add new page you can add an
CODE
else if( $page == 'PAGEID') {
echo "Page content goes here";
}
Make sure it is places before the else statement.
PAGEID Doesn't have to be a number it can be letters too.
HERE is a
preview