hi i have noticed alot of php sites,
rather than linking to a page name or file name
they link using id's?
and i was wondering how to do this..
and the benefits of it..
if you could help it wld b greatly appreciated!
my thanx in advance
~ Aaron ~
Download id thingys!!??
Moderator: General Moderators
-
UK_Trickster
- Forum Newbie
- Posts: 2
- Joined: Sun Jul 20, 2003 3:23 pm
- Location: london
- Contact:
- ILoveJackDaniels
- Forum Commoner
- Posts: 43
- Joined: Mon May 20, 2002 8:18 am
- Location: Brighton, UK
There are several benefits, the obvious ones being the ability to track downloads easily, and being able to force downloads of files (linking directly to a php file will normally mean it runs, rather than downloading).
It is normally done with a script that, once it's done the tracking or whatever, just redirects the browser to the relevant file, or sets headers and reads the file directly...
It is normally done with a script that, once it's done the tracking or whatever, just redirects the browser to the relevant file, or sets headers and reads the file directly...
-
UK_Trickster
- Forum Newbie
- Posts: 2
- Joined: Sun Jul 20, 2003 3:23 pm
- Location: london
- Contact:
-
kettle_drum
- DevNet Resident
- Posts: 1150
- Joined: Sun Jul 20, 2003 9:25 pm
- Location: West Yorkshire, England
...
All you need to do is accept the page you want to show as a GET variable in the url. Then in your page have some function/if statement to check to see if the GET value is set and if it is then have it parse the data and then load the required page.
I.e
Have a link in your page to - index.php?page=about_us
Then in your index.php pages code have something like:
Just have a go playing about with doing it yourself and see how you like it. If you like spliting up your files into different directorys then you could also pass the directory name in the url as well, e.g.:
index.php?section=members&page=edit_profile
If you are going to do stuff like this make sure you hard code a path name to the include statement to avoid anybody being able to load files you dont want them to.
Hope this helps you out a bit.
I.e
Have a link in your page to - index.php?page=about_us
Then in your index.php pages code have something like:
Code: Select all
if($_GETїpage]){
include($path_to_files."/".strtolower($_GETїpage]).".php");
}index.php?section=members&page=edit_profile
If you are going to do stuff like this make sure you hard code a path name to the include statement to avoid anybody being able to load files you dont want them to.
Hope this helps you out a bit.