Web Hosting Deals Holiday Logo Design Webcam Chat Website Header Templates Register domain Search Engine Optimisation Web Hosting
Go Back   Talk Mania Forum > Tutorials > PHP / Perl / Java / JavaScript / CGI Tutorials

PHP / Perl / Java / JavaScript / CGI Tutorials PHP / Perl / Java / JavaScript / CGI Tutorials Please do not use this Forum to advertise your site or to link to tutorials.

 Image
Buy Sell Downloads

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-17-2007, 03:40 AM
Base's Avatar
Senior Member
 
Join Date: Mar 2007
Location: North Yorkshire, UK
Posts: 121
Base is on a distinguished road
Send a message via MSN to Base Send a message via Skype™ to Base
PHP tutorial, for PHP navigation.

Allot of people ask me how to do those "cool" page nav URL's in PHP

i.e. http://www.yourwebsite.com/index.php?page=downloads

Thos things...

So in this tutorial i am going to explain how to do it!

This is pretty baisic code so it shouldn't get too confusing.

PHP Code:
<?php
switch ($HTTP_GET_VARS[page]) 

{


// Default page
default:

include 
"site/index.php";

break;

// Downloads page
case 'resources=downloads':

include 
'site/downloads.php';

break;

//Scripts - case
case 'resources=scripts':

include 
'site/scripts.php';

break;


}
?>
the first thing you need to notice is this bit

"$HTTP_GET_VARS[page]" now this bit is the main part, the bit where is says [page] thats what the file is going to be, so for this example to get to the downloads page we go to

index.php?page=downloads

But if you changed that [page] to say [nav] then it would be

index.php?nav=downloads

"default:" this is the next bit you need to think about, this is your default page, so say if someone just went to index.php then this is the bit that would be told to display.

include "site/index.php"; This is most likely the phrase you will use the most at a baisic level of PHP, this is the include page tag, so in this case we are saying

If someone points there browser to www.yoursite.com/index.php then its going to include the file site/index.php

"break;" This bit is just telling the server that thats the end of the code for that case.

case 'resources=downloads': This is for the downloads page, so when someone visits www.yourwebsite.com/index.php?page=downloads then its going to include site/downloads.php

"}"
This is telling the server, that your now not defining the contents of [page]

Right then!

Summing up:


switch ($HTTP_GET_VARS[page]) - You change the "page" thing to what you want it to be..

i.e. if you want it to be index.php?number=somthing

then you change it from switch ($HTTP_GET_VARS[page])

to

switch ($HTTP_GET_VARS[number])


case 'resources=downloads': - for this you must remmeber not to remove the "resources=" bit if you do, it won't work!

but the bit after the = sign, change that to what you want to be.

So final example.

PHP Code:
<?php
switch ($HTTP_GET_VARS[nav]) 

{


// Default page
default:

include 
"news.php";

break;

// Forums
case 'resources=forums':

include 
'forums/index.php';

break;

// Downloads page
case 'resources=downloads':

include 
'downloads.php';

break;


}
?>
*** THINGS TO REMEMBER ***


The fact that i have used index.php?somthing=somthing in this example means nothing..

you can put this on any page that you want so it could be

www.youresite.com/porn.php?type=lesbian if you so desired :P

Hope you all got it, and enjoyed it and have learned somthing!

Cheers

Base

__________________
http://www.pointserv.co.uk/gfx/deal_..._pointserv.png
PointServ.co.uk - One of the UK's cheapest webhosting companies.
Reply With Quote
  #2 (permalink)  
Old 03-18-2007, 07:54 AM
Junior Member
 
Join Date: Mar 2007
Posts: 10
cobalt is on a distinguished road
ive known how to do this for a while but its nice to finally see someone explaining it.
Reply With Quote
  #3 (permalink)  
Old 03-18-2007, 05:21 PM
Junior Member
 
Join Date: Mar 2007
Posts: 10
Drompo is on a distinguished road
Good TUT. Thanks
Reply With Quote
  #4 (permalink)  
Old 03-18-2007, 07:02 PM
Turbocharged_06's Avatar
VIP Member
 
Join Date: Mar 2007
Posts: 151
Turbocharged_06 is on a distinguished road
Exclamation

.......................
__________________
OUTLAW-WEB.NET

Last edited by Turbocharged_06; 05-28-2007 at 12:42 AM.
Reply With Quote
  #5 (permalink)  
Old 03-18-2007, 11:00 PM
Junior Member
 
Join Date: Mar 2007
Posts: 10
pob944 is on a distinguished road
goog to make a script
Reply With Quote
  #6 (permalink)  
Old 03-19-2007, 01:16 AM
Base's Avatar
Senior Member
 
Join Date: Mar 2007
Location: North Yorkshire, UK
Posts: 121
Base is on a distinguished road
Send a message via MSN to Base Send a message via Skype™ to Base
Quote:
Originally Posted by Turbocharged_06 View Post
Vulnerable to RFI can be used to
index.php?page=../../../../../../../etc/passwd
What are you talking about?

you can't previous directory using this function.

Base
__________________
http://www.pointserv.co.uk/gfx/deal_..._pointserv.png
PointServ.co.uk - One of the UK's cheapest webhosting companies.
Reply With Quote
  #7 (permalink)  
Old 03-26-2007, 05:50 PM
Junior Member
 
Join Date: Mar 2007
Posts: 20
tere is on a distinguished road
Thanks for this greate tutorial!
Reply With Quote
  #8 (permalink)  
Old 03-26-2007, 06:26 PM
Base's Avatar
Senior Member
 
Join Date: Mar 2007
Location: North Yorkshire, UK
Posts: 121
Base is on a distinguished road
Send a message via MSN to Base Send a message via Skype™ to Base
cheers for the comments lads!

Base
__________________
http://www.pointserv.co.uk/gfx/deal_..._pointserv.png
PointServ.co.uk - One of the UK's cheapest webhosting companies.
Reply With Quote
  #9 (permalink)  
Old 03-28-2007, 12:56 AM
Junior Member
 
Join Date: Mar 2007
Posts: 25
Willyke is on a distinguished road
Quote:
Originally Posted by Turbocharged_06 View Post
Vulnerable to RFI can be used to
index.php?page=../../../../../../../etc/passwd
It isn't vurnerable to RFE... this is because every input is checked with the Case-structure
Only the page that are defined there will be shown not anything else because it isn't working with include($HTTP_GET_VARS[page]).

----

Nicely written Base, keep it up
Reply With Quote
  #10 (permalink)  
Old 03-29-2007, 03:14 AM
Junior Member
 
Join Date: Mar 2007
Posts: 15
daoner is on a distinguished road
finally i found this! thanks.

Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT +2. The time now is 05:12 PM.


Fake ID

Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0 RC8
Forums Copyright © Talk-Mania.com