|
| Web Hosting Deals | Holiday Logo Design | Webcam Chat | Website Header Templates | Register domain | Search Engine Optimisation | Web Hosting |
|
|||||||
| 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. |
![]() |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
||||
|
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:
"$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:
*** 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. |
|
||||
|
.......................
__________________
OUTLAW-WEB.NET Last edited by Turbocharged_06; 05-28-2007 at 12:42 AM. |
|
||||
|
Quote:
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. |
|
||||
|
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. |
|
|||
|
Quote:
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 ![]() |
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|