ev5unleash Posted June 28, 2008 Share Posted June 28, 2008 Alright, What I want to do is have a normal website /index.php (with no php errors) but when a link like /index.php?page=news.php shows /homepage/news.php. Can anyone help me please? Link to comment https://forums.phpfreaks.com/topic/112327-solved-php-include/ Share on other sites More sharing options...
imdead Posted June 28, 2008 Share Posted June 28, 2008 <?php $page = $_GET['page']; switch ($page) { default: include "/homepage/news.php"; break; case 'login': include '/homepage/login.php'; break; case 'signup': include '/homepage/signup.php'; break; } ?> Link to comment https://forums.phpfreaks.com/topic/112327-solved-php-include/#findComment-576693 Share on other sites More sharing options...
bsamson Posted June 28, 2008 Share Posted June 28, 2008 I don't know if it matters but the method I have opted for is a url like: index.php?id=help Then I created a script that I include in my template that looks like this: <?php // Check if first visit if ($_GET['id'] == "") { header("Location: http://www.mydomain.com/index.php?id=main"); } // Determine Tool to load $pg2Load = $_GET['id']; // Load Main Site Page $filename = '/home/nxsap/www/pg_'.$pg2Load.'.php'; if (file_exists($filename)) { $pgID = "pg_".$pg2Load.'.php'; } else { header("Location: http://www.mydomain.com/index.php?id=main"); } ?> With this method there is no need to include the PHP extention. Basically as your site grows you simply name the new page pg_PAGENAME.php and there is no need to worrying telling a script what the new page name is. Link to comment https://forums.phpfreaks.com/topic/112327-solved-php-include/#findComment-576695 Share on other sites More sharing options...
ev5unleash Posted June 28, 2008 Author Share Posted June 28, 2008 You don't get it, I want it so when people go to my website http://www.ev5unleash.com (/index.php) it would show the homepage (/home.php file). But when something like /index.php?page=news it will show /homepage/news/news.html instead of home.php. Link to comment https://forums.phpfreaks.com/topic/112327-solved-php-include/#findComment-576699 Share on other sites More sharing options...
br0ken Posted June 28, 2008 Share Posted June 28, 2008 This is what you want. This select statement will take the value in page and if it finds that value in the switch statement, display the approrpriate page. If however the value in page is not in the list or is empty it will the run the default section which displays the homepage. switch(strtolower($_GET['page'])) { case "news": include("/homepage/news/news.html"); break; case "contact": include("/homepage/contact/contact.html"); break; default: include("/home.php"); break; } Link to comment https://forums.phpfreaks.com/topic/112327-solved-php-include/#findComment-576709 Share on other sites More sharing options...
ev5unleash Posted June 28, 2008 Author Share Posted June 28, 2008 This is perfect THANK YOU! ;D ;D This can be closed now Link to comment https://forums.phpfreaks.com/topic/112327-solved-php-include/#findComment-576711 Share on other sites More sharing options...
br0ken Posted June 28, 2008 Share Posted June 28, 2008 To mark the thread as solved you need to click the 'TOPIC SOLVED' link at the bottom left of the screen. Link to comment https://forums.phpfreaks.com/topic/112327-solved-php-include/#findComment-576718 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.