sweetique Posted November 6, 2007 Share Posted November 6, 2007 I have includes in my site based on page='page' What i want to know is.. can i somehow, if it can't find the include, redirect to another include file? Link to comment https://forums.phpfreaks.com/topic/76191-solved-php-include-question/ Share on other sites More sharing options...
~n[EO]n~ Posted November 6, 2007 Share Posted November 6, 2007 Try like this <?php if ($pagefound) { include ("page1.php"); } else { include ("page2.php"); } ?> Link to comment https://forums.phpfreaks.com/topic/76191-solved-php-include-question/#findComment-385582 Share on other sites More sharing options...
sweetique Posted November 6, 2007 Author Share Posted November 6, 2007 thanks I will try this Link to comment https://forums.phpfreaks.com/topic/76191-solved-php-include-question/#findComment-385587 Share on other sites More sharing options...
sweetique Posted November 6, 2007 Author Share Posted November 6, 2007 It kind of works. Code I was already using. <?php $page = $_GET['page']; include ("$page.htm"); ?> your code <?php if ($pagefound) { include ("$page.htm"); } else { include ("notavailable.htm"); } ?> the "notavailable.htm" shows up on the bottom of every page Link to comment https://forums.phpfreaks.com/topic/76191-solved-php-include-question/#findComment-385602 Share on other sites More sharing options...
~n[EO]n~ Posted November 6, 2007 Share Posted November 6, 2007 You should change the variable names <?php if (isset($page)) { include ("page.htm"); } else { include ("notavailable.htm"); } ?> Link to comment https://forums.phpfreaks.com/topic/76191-solved-php-include-question/#findComment-385603 Share on other sites More sharing options...
sweetique Posted November 6, 2007 Author Share Posted November 6, 2007 >.> Thanks again... I don't really know any php. I really should have paid more attention in class XD Link to comment https://forums.phpfreaks.com/topic/76191-solved-php-include-question/#findComment-385604 Share on other sites More sharing options...
sweetique Posted November 6, 2007 Author Share Posted November 6, 2007 oh noes!! now it only shows the notavailable page -.-''' Link to comment https://forums.phpfreaks.com/topic/76191-solved-php-include-question/#findComment-385607 Share on other sites More sharing options...
~n[EO]n~ Posted November 6, 2007 Share Posted November 6, 2007 $page = $_GET['page']; from where are you getting this ??? Link to comment https://forums.phpfreaks.com/topic/76191-solved-php-include-question/#findComment-385608 Share on other sites More sharing options...
sweetique Posted November 6, 2007 Author Share Posted November 6, 2007 some tutorial on here i believe @.@ it works -the get thingy. but like i said i wanted it to go to include another page if the original include couldn't be found. I was trying to avoid having to code 26 pages or so Link to comment https://forums.phpfreaks.com/topic/76191-solved-php-include-question/#findComment-385612 Share on other sites More sharing options...
~n[EO]n~ Posted November 6, 2007 Share Posted November 6, 2007 You should study some tutorials on GET and POST www.tizag.com/phpT/postget.php Link to comment https://forums.phpfreaks.com/topic/76191-solved-php-include-question/#findComment-385614 Share on other sites More sharing options...
rajivgonsalves Posted November 6, 2007 Share Posted November 6, 2007 should be <?php $page = $_GET['page']; if (file_exist("$page.html")) { include ("$page.htm"); } else { include ("notavailable.htm"); } ?> Link to comment https://forums.phpfreaks.com/topic/76191-solved-php-include-question/#findComment-385615 Share on other sites More sharing options...
sweetique Posted November 6, 2007 Author Share Posted November 6, 2007 Thank you that did work. Much appreciated Link to comment https://forums.phpfreaks.com/topic/76191-solved-php-include-question/#findComment-385620 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.