Page 1 of 1
Download id thingys!!??
Posted: Sun Jul 20, 2003 3:23 pm
by UK_Trickster
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 ~
Posted: Sun Jul 20, 2003 4:38 pm
by ILoveJackDaniels
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...
Posted: Sun Jul 20, 2003 4:46 pm
by UK_Trickster
hiya, thanx for that...
but how do i go bout settin it up n stuff?? (as u can tel i am quite new to PHP)

...
Posted: Sun Jul 20, 2003 9:38 pm
by kettle_drum
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:
Code: Select all
if($_GETїpage]){
include($path_to_files."/".strtolower($_GETїpage]).".php");
}
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.