Download id thingys!!??

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
UK_Trickster
Forum Newbie
Posts: 2
Joined: Sun Jul 20, 2003 3:23 pm
Location: london
Contact:

Download id thingys!!??

Post 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 ~
User avatar
ILoveJackDaniels
Forum Commoner
Posts: 43
Joined: Mon May 20, 2002 8:18 am
Location: Brighton, UK

Post 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...
UK_Trickster
Forum Newbie
Posts: 2
Joined: Sun Jul 20, 2003 3:23 pm
Location: london
Contact:

Post 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) 8O
kettle_drum
DevNet Resident
Posts: 1150
Joined: Sun Jul 20, 2003 9:25 pm
Location: West Yorkshire, England

...

Post 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.
Post Reply