I'm building a website - www.ucljsoc.com, please take a look... the problem is that the homepage doesn't appear, but the area around it does. I have used the include command so that the top, bottom and the left sides of the page remain constant. This saves bandwidth and loading times. Unfortunately my knowledge of PHP is somewhat limited, and my google searches have been renedered fruitless! Therefore I turn to you... I want the page http://www.ucljsoc.com/index.php?page=home to load automatically when www.ucljsoc.com is typed in. Have a look at my PHP: ------------------------------------------------------------------------ $p = $_GET['page']; $pages = array("home","register", "sign_in", "events", "photogallery", "about", "contact_us", "campaigns", "education", "fundraising", "welfare", "sponsorship", "competitions", "freshers", "commitee", "hillel_news", "halls", "timetable", "shabbat", "fun_and_games"); if (in_array ($p,$pages)) { if (!$p) { $p = "home"; } include "$p.php"; } else { echo "<font color = 'White' size=2>The www.ucljsoc.com server cannot find your page. <BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR>Instead of an impersonal generated message, I will leave a more personalised generated message here:<BR><BR><BR><BR>You either mis-typed the address, or the page that you want no longer exists.<BR>Either way, get in touch with us, and we'll do our best to rectify the problem.</font>"; } ----------------------------------------------------------------------
Try this: $p = $_GET['page']; $pages = array("home","register", "sign_in", "events", "photogallery", "about", "contact_us", "campaigns", "education", "fundraising", "welfare", "sponsorship", "competitions", "freshers", "commitee", "hillel_news", "halls", "timetable", "shabbat", "fun_and_games"); if (!$p) { $p = "home"; } if (in_array ($p,$pages)) { include "$p.php"; } else { echo "<font color = 'White' size=2>The www.ucljsoc.com server cannot find your page. <BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR>Instead of an impersonal generated message, I will leave a more personalised generated message here:<BR><BR><BR><BR>You either mis-typed the address, or the page that you want no longer exists.<BR>Either way, get in touch with us, and we'll do our best to rectify the problem.</font>"; } PHP:
I would do it this way.. no need to have a page array $page = isset($_GET['page'])? $_GET['page'].'.php' : 'home.php'; if ( file_exists($page) ) include $page; else echo "no Page";