First off be sure to use the [ php ] [/php ] brackets, to make your code tighty.
Secondly, your method isn't secure, but use $_GET.
if( isset( $_GET['page'] ) ) {
$page = $_GET['page'];
}
if( isset( $page ) ) {
include( $page );
} else {
include("main.php");
}
Now be careful however, this is easily exploited. I recommend doing something like this...
//...
if( isset( $page ) ) {
if( $page == "news" ) {
include( "news.php" );
} elseif( $page =="otherpage") {
include( "otherpage.php" );
} else {
include( "main.php")
}
}
This is really rough code, but be careful when using $_GET. It's easily exploited. I'm still learning too, so if there's anything wrong with my method please shout out 🙂.