It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming PHP and MySQL Forum

How can I incorporate an if statement here?

Moderator: Malcolm

How can I incorporate an if statement here?

Postby dflynn on Thu Dec 18, 2008 6:19 pm

I'm having trouble with this bit of code
Code: Select all
$ page = $ _GET [' page ' ];
   echo "<h1>" .  strtoupper( $ page) . "</h1>";
   @ include "inc/" . $ page . ". php";


is there a way to make it so that if the url is simply index.php it loads the content of the home page?
User avatar
dflynn
500+ Club
 
Posts: 860
Joined: Wed Oct 03, 2007 9:06 pm
Location: Guelph, Canada

Re: How can I incorporate an if statement here?

Postby flabbyrabbit on Thu Dec 18, 2008 7:25 pm

Code: Select all
if (isset($ _GET['page'])) {
   $ page = $ _GET['page'];
   echo "<h1>" .  strtoupper( $ page) . "</h1>";
   @ include "inc/" . $ page . ". php";
} else {
   //Homepage stuff here
}
Image
User avatar
flabbyrabbit
500+ Club
 
Posts: 706
Joined: Thu Jan 25, 2007 1:10 pm
Location: Midlands, England

Re: How can I incorporate an if statement here?

Postby dflynn on Thu Dec 18, 2008 8:43 pm

Ahh ofcourse! thank you very much flabbyrabbit.
i should have been able to figure that out... should probably take more breaks. :P
User avatar
dflynn
500+ Club
 
Posts: 860
Joined: Wed Oct 03, 2007 9:06 pm
Location: Guelph, Canada


Who is online

Users browsing this forum: No registered users and 1 guest