How to make a link by PHP

hi guys,
I really don’t know and understand how they can create a link like: index.php?link=hoepage or link=contact to go to a new page ? and when they do it, what is the advantage of this PHP link compare to html link ?

thanks all

That is a post variable and not a php link. You can make one page called say index.php that is blank but except for some PHP code in there that uses switch/case statements to check the value of the post variable and then include a file. This is cool because it makes your site smaller. What I do is use include tags for this but I put my header above the switch/case statement and my footer below it so I don’t have to maintain the extra code and can just change it in 1 place.

Here is a link to a tutorial regarding it:
http://robouk.mchost.com/tuts/tutorial.php?tutorial=variables

And basically, it enables you to reduce the size of your website as DP said. You could even have it so that your website consists of only one PHP page and depending on the query string (e.g. the “?page=home” of http://www.yourwebsite.com/index.php?page=home) you could have it include/read/require text or images or both from different files and display them in a certain area of the page.

ah I see, it’s very usefull, thanks all for your helping

Any time :).

*Originally posted by DigitalPimp *
**That is a post variable and not a php link. **
That’s a GET variable :wink:

Actually, it can be either. A post is more secure because the query string is passed but not included in the URL unlike a GET which does show the query string in the URL. :wink:

Just remember ahmed :p: here.

hehe jk

when saying

Actually, it can be either. A post is more secure because the query string is passed but not included in the URL unlike a GET which does show the query string in the URL.

you’re contradicting yourself, the query string is included in the url, so how can it be a post var?.. who cares anyway, both work :slight_smile:

No I’m not. In a post the query string is passed to the next page but you can’t see it… In a get the same data is passed but it appears in the URL.

I guess get var when a user submit a value and the URl will bring this var to new page

@ digi:
indeed, and the example was

index.php?link=hoepage
, so i guess you can see it…so it couldn’t be post… as i said, both work, so who cares…

hi all again,
now I can do it easily, but I wonder if I correct this code:


else if ($vietxuan == "partners") {
echo ("partners");
if ($page == "1") {
include ("partners.php"); 
}
else if ($page == "2") {
include ("partners2.php"); 
}
else if ($page == "3") {
include ("partners3.php");
}
else if ($page == "4") {
include ("partners4.php"); 
} 

and this is result: http://www.vietxuanltd.com/index.php?vietxuan=partners&page=1

I found some address they use ; or :: instead of & , please tell me when will we need to use those characters , and what different from each other ?
thanks guys for your time to read this.

replace

if ($page == "1") {
include ("partners.php"); 
}
else if ($page == "2") {
include ("partners2.php"); 
}
else if ($page == "3") {
include ("partners3.php");
}
else if ($page == "4") {
include ("partners4.php"); 
}  

with


include ("partners".$page.".php");