Multiple Pages - One Page

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
nickman013
Forum Regular
Posts: 764
Joined: Sun Aug 14, 2005 12:02 am
Location: Long Island, New York

Multiple Pages - One Page

Post by nickman013 »

Hello,

I need help making a script for my page.

I would like to make a index.php page and then when ?page=home is added to that, it goes to the home page, when ?page=aboutus is added to that it goes to the About Us page.

ex.

http://www.mysite.com/index.php?page=home - Home Page
http://www.mysite.com/index.php?page=contactus - Contact Us Page
http://www.mysite.com/index.php3page=support - Support Page


If possible can someone just show me a simple script.

A Website that uses the page script I want is http://www.edgz.com.

Thank You
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

check out "Proper use of $_GET with includes: $_GET and include" link found in the Usefull Posts Thread
User avatar
nickman013
Forum Regular
Posts: 764
Joined: Sun Aug 14, 2005 12:02 am
Location: Long Island, New York

Post by nickman013 »

ok, I found a code that i think is right...

Code: Select all

<?
switch ($_GET['file']) { 
    case "index": include("index.inc.php"); break; 
    case "file1": include("file1.inc.php"); break; 
    case "file2": include("file2.inc.php"); break; 
    case "file3": include("file3.inc.php"); break; 
    default: include("index.inc.php"); break; 
}

?>
so if i wanted to go to the index page, my link would be http://www.mysite.com/index.php?file=index

because if thats the case i get a parse error
Parse error: parse error, expecting `'}'' in /web/u54/www22882/www/nicky/get33.php3 on line 3
I get the error without putting the ?file=index after the url anyway.
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: Multiple Pages - One Page

Post by josh »

nickman013 wrote: A Website that uses the page script I want is http://www.edgz.com.
A website that does it *wrong* I might add

Edit: Is that your entire script, or is line 3 something different?
User avatar
nickman013
Forum Regular
Posts: 764
Joined: Sun Aug 14, 2005 12:02 am
Location: Long Island, New York

Re: Multiple Pages - One Page

Post by nickman013 »

jshpro2 wrote:
nickman013 wrote: A Website that uses the page script I want is http://www.edgz.com.
A website that does it *wrong* I might add
:D lol
Charles256
DevNet Resident
Posts: 1375
Joined: Fri Sep 16, 2005 9:06 pm

Post by Charles256 »

wow..that page blindly trusts that URL..blindly...way blindly..oh my lord...someone e-mail him! (i'm too lazy:) )
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Post by josh »

or instead of emailing him, write him a message on his home page, hell take it more seriously :lol:
Post Reply