View Full Version : how to make a link by PHP
OKtrust
July 31st, 2003, 02:27 PM
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
DigitalPimp
July 31st, 2003, 02:59 PM
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.
JK87
July 31st, 2003, 03:16 PM
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.
OKtrust
July 31st, 2003, 11:45 PM
ah I see, it's very usefull, thanks all for your helping
JK87
August 1st, 2003, 03:35 AM
Any time :).
ahmed
August 1st, 2003, 03:52 AM
Originally posted by DigitalPimp
That is a post variable and not a php link. That's a GET variable ;)
DigitalPimp
August 1st, 2003, 04:29 AM
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. ;)
Just remember ahmed :p: here.
hehe jk
eyezberg
August 1st, 2003, 01:17 PM
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 :)
DigitalPimp
August 1st, 2003, 01:23 PM
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.
OKtrust
August 1st, 2003, 01:25 PM
I guess get var when a user submit a value and the URl will bring this var to new page
eyezberg
August 2nd, 2003, 12:47 PM
@ 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..
OKtrust
August 23rd, 2003, 02:24 PM
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.
eyezberg
August 23rd, 2003, 06:33 PM
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");
...
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.