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? Quote Link to comment 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"); } ?> Quote Link to comment Share on other sites More sharing options...
sweetique Posted November 6, 2007 Author Share Posted November 6, 2007 thanks I will try this Quote Link to comment 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 Quote Link to comment 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"); } ?> Quote Link to comment 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 Quote Link to comment 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 -.-''' Quote Link to comment 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 ??? Quote Link to comment 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 Quote Link to comment 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 Quote Link to comment 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"); } ?> Quote Link to comment 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.