Jump to content

Archived

This topic is now archived and is closed to further replies.

bigun

Tracking Downloading With Php

Recommended Posts

I'd like to be able to tell when a download is finished downloading by a user. I've googled until my eyes are dry, and I've had no luck.

Or if anyone can tell me how to make a link that will allow someone to download a file, then after it is finished the link will go dead.

Share this post


Link to post
Share on other sites
[!--quoteo(post=388650:date=Jun 27 2006, 09:27 PM:name=bigun)--][div class=\'quotetop\']QUOTE(bigun @ Jun 27 2006, 09:27 PM) [snapback]388650[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Or if anyone can tell me how to make a link that will allow someone to download a file, then after it is finished the link will go dead.
[/quote]

In the database have.

users_id
time
date
users_ip
downloaded

dowload

[code]

<?session_start(); //if user session is present and is set as $user_id

//select database

$db=mysql_connect("localhost","name","password" );
mysql_select_db($db);

// query the database if the user is in the database where user_id=$user_id.

$query="select *  from downloads where time=$time and date=$date and
user_ip=$user_ip and user_id=$user_id";

$result=mysql_query($query);

// if the user is not in the database then let them see the link and down load.

if(mysql_num_rows($result)==0)) {

$time=date("his");
$date=date("dmy");
$user_ip=$_SERVER['REMOTE_ADDR']:
?>

<a href="download_result?&user_id=$user_id&time=$time&date=$date&user_ip=$user_ip">download file</a>
<?

//else if the user is in the database echo sorry message.
}else{

echo "sorry you have downloaded already";

}
[/code]

I tried ok.

Share this post


Link to post
Share on other sites
You can't really accomplish that with PHP. You need something like a Java applet or Flash that has interaction on the user end. PHP isn't designed to do that.

Share this post


Link to post
Share on other sites
Ehh... not quite as clean as I hoped it would be...

Is there some way to maybe have a timer that only allows the link to be good for 30 minutes or so?

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.