PHP Pages

 
Post new topic   Reply to topic    Aprelium Forum Index -> PHP
View previous topic :: View next topic  
Author Message
AbyssUnderground
-


Joined: 31 Dec 2004
Posts: 3855

PostPosted: Tue Feb 08, 2005 9:03 pm    Post subject: PHP Pages Reply with quote

Hello,

I am fairly new to the world of PHP and I was wondering how I incorporate serveral pages into one php script page such as index.php and then add ?mypage to the end of the filename to bring up another page.

E.G http://www.m3ezw.co.uk/index.php?home will bring up the homepage
http://www.m3ezw.co.uk/index.php?downloads will bring up the downloads page.

I have seen this done with many scripts and have spent hours trying to do it myself but I can never seem to get it to work. Any simple script on how to get this to work will be greatly appriciated.

Thanks.
_________________
Andy (AbyssUnderground) (previously The Inquisitor)
www.abyssunderground.co.uk
Back to top View user's profile Send private message Visit poster's website
MonkeyNation
-


Joined: 05 Feb 2005
Posts: 921
Location: Cardiff

PostPosted: Tue Feb 08, 2005 10:46 pm    Post subject: Reply with quote

It took me a while to figure this out too. But its so simple.

http://62.249.233.57/test6.php?georgebush=retarded
http://62.249.233.57/test6.php?georgebush=normal

They will bring up different text each time.
The source to this is
Code:

<?php
$gb = $_GET['georgebush'];
if ($gb == "retarded") {
echo "YO DAMN RIGHT!";
}
if ($gb == "normal") {
echo "WTF ARE YOU TAKING, YOU KNOW YOUR WRONG!";
}
?>


Its the $_GET that does this, if you were to do $_GET['page'] then you would end up with page? . But im sure you've figured this by now.

There are probably other ways of doing this, but this is the only way I have.
Have fun with it :D
_________________
Back to top View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger ICQ Number
Glitch2082
-


Joined: 02 Dec 2004
Posts: 194

PostPosted: Tue Feb 08, 2005 11:17 pm    Post subject: Reply with quote

You can also use case etc...
But the way your doing it you would use include, instead of echoing it in order to go to the page. Just thought I should inform 'The Inquister' of this.
_________________
int main() {
cout << "Im Pro Apache";
cin.get();
}
Back to top View user's profile Send private message Send e-mail
mrkill47
-


Joined: 12 Jan 2005
Posts: 17
Location: 127.0.0.1

PostPosted: Wed Feb 09, 2005 1:18 pm    Post subject: Reply with quote

make a page template with all your layout info and stuff.

in the part where the content should go put:

Code:
$_GET['page'] = isset($_GET['page']) ? $_GET['page'] : NULL;

switch( $_GET['page'] ) {

   case 'test' :   
      include 'test.php';
      break;

   case 'about' :   
      include 'about.php';
      break;

   case 'forum' :   
      include 'forum.php';
      break;

    default:   
        include 'main.php';
        break;

}


If someone goes to http://www.yoursite.com/index.php?page=about it will show the about page. what the php script will do is include the contents of the file "about.php" (which is just raw content).

you can edit the code above to suit your site. i have also included a default case so that if someone goes to www.yoursite.com/index.php (with the ?page=) it will include a default page.
_________________
http://fnar.sytes.net <<--- Powered by Abyss :D
Back to top View user's profile Send private message Visit poster's website MSN Messenger
AbyssUnderground
-


Joined: 31 Dec 2004
Posts: 3855

PostPosted: Wed Feb 09, 2005 6:01 pm    Post subject: Reply with quote

Thanks for your help, I am going to give it a go now.

The address for the site I will be using it for is http://82.9.140.66 but it won't be online until sunday.

Cheers.
_________________
Andy (AbyssUnderground) (previously The Inquisitor)
www.abyssunderground.co.uk
Back to top View user's profile Send private message Visit poster's website
MonkeyNation
-


Joined: 05 Feb 2005
Posts: 921
Location: Cardiff

PostPosted: Wed Feb 09, 2005 6:25 pm    Post subject: Reply with quote

mrkill47 wrote:
make a page template with all your layout info and stuff.

in the part where the content should go put:

Code:
$_GET['page'] = isset($_GET['page']) ? $_GET['page'] : NULL;

switch( $_GET['page'] ) {

   case 'test' :   
      include 'test.php';
      break;

   case 'about' :   
      include 'about.php';
      break;

   case 'forum' :   
      include 'forum.php';
      break;

    default:   
        include 'main.php';
        break;

}


If someone goes to http://www.yoursite.com/index.php?page=about it will show the about page. what the php script will do is include the contents of the file "about.php" (which is just raw content).

you can edit the code above to suit your site. i have also included a default case so that if someone goes to www.yoursite.com/index.php (with the ?page=) it will include a default page.


Thanks also, I learnt somthing new today :D
_________________
Back to top View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger ICQ Number
AbyssUnderground
-


Joined: 31 Dec 2004
Posts: 3855

PostPosted: Wed Feb 09, 2005 8:59 pm    Post subject: Reply with quote

This script is perfect and just what I was looking for, thanks mrkill47!
_________________
Andy (AbyssUnderground) (previously The Inquisitor)
www.abyssunderground.co.uk
Back to top View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Aprelium Forum Index -> PHP All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB phpBB Group