|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
generate random link to url
I am after a bit of advice on how to write a script that will generate a link to a file that will only work once.
i.e. the script is called and it generates a link http://mydomain.com/12345.....filename.zip this link would only remain valid for either a set time or a one off click through. The next time the script is called it would give a different url i.e. http://mydomain.com/53762.....filename.zip I'm not too sure where to start. Perhaps linking in to a mysql database? |
|
#2
|
|||
|
|||
|
If you are willing to use a link something like "http://mydomain.com/file.php?c=12345&n=filename.zip", then you could try something like this:
Create a table in mySQL with the fields 'code' (varchar(xx) where 'xx' is the length of your secret code), 'filename' (varchar(yy) where 'yy' is the maximum length of a file's name), and 'expires' (DATETIME). In the file that gives the link to the user: PHP Code:
In the file 'file.php': PHP Code:
|
|
#3
|
||||
|
||||
|
hmmm looks good.
I will now go and have a play. Thanks |
|
#4
|
||||
|
||||
|
In the file.php code are the variables
PHP Code:
classed as globals? If I turn register_globals off on my server will I have define these first? i.e. PHP Code:
|
|
#5
|
|||
|
|||
|
In a word... Yes.
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages > PHP Development > generate random link to url |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|