Page fetching problem

my current code for getting a page is

	<?php 
		$page = $_GET['page'];  //Gets the (page=) from the URL
  		if($page){  
  		$site = file_exists($page.'.html') ? $page.'.html' : 'home.html';}
  		else{
  		$site = 'home.html'; // Else include the default home.php file.       
  		}
  		include($site);
	?>

the problem with it is it only checks for html pages.
I would like to have it check for html then php pages and it pull up whichever is valid.

i tried to do it myself but im a php n00b. pls help

       	<?php 
		$page = $_GET['page'];  //Gets the (page=) from the URL
  		if($page){  
  		$site = file_exists($page.'.html') ? $page.'.html' : 'home.html';}
  		elseif
  		$site = file_exists($page.'.php') ? $page.'.php' : 'home.html';
		else{$site = 'home.html'; // Else include the default home.php file.       
  		}
  		include($site);
			?>

^^ is what i did. any help will be appreciated. Thanks

thanks so much :slight_smile:

You almost had it bud, just needed a few changes

<?php

    $page = $_GET['page'];  //Gets the (page=) from the URL
    
    if (file_exists($page.'.html')){ 
        $site = $page.'.html';
    } elseif (file_exists($page.'.php')){
        $site = $page.'.php';
    } else{
        $site = 'home.html'; // Else include the default home.php file.       
    }
      
    include($site);
    
?>