Free file hosting, free video sharing

<<< The Web Hosting >>>


Go Back   Noeman GSM > Webhosting & Website development > Website development > Programming

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-26-2007, 03:54 PM
Spiral's Avatar
CO-Admin
 
Join Date: Sep 2004
Location: Martil
Age: 25
Posts: 16,761
Reputation: 29697
Spiral Mega Super MemberSpiral Mega Super MemberSpiral Mega Super MemberSpiral Mega Super MemberSpiral Mega Super MemberSpiral Mega Super MemberSpiral Mega Super MemberSpiral Mega Super MemberSpiral Mega Super MemberSpiral Mega Super MemberSpiral Mega Super Member
Default PHP tutorial, for PHP navigation.

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

i.e. [Only Registered users can see links . Click Here To Register...]

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 [Only Registered users can see links . Click Here To Register...] 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 [Only Registered users can see links . Click Here To Register...] 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

[Only Registered users can see links . Click Here To Register...] if you so desired :P

Hope you all got it, and enjoyed it and have learned somthing!
Reply With Quote
Sponsored Links
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


All times are GMT. The time now is 09:21 PM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
Copyright © 2004-2008 Noeman . All rights reserved
Loans | Costa Blanca Car Sales | Home Loan | Loans | Free Music Downloads

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114