Jump to content

Tracking Downloading With Php


bigun

Recommended Posts

[!--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.

Archived

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

×
×
  • Create New...

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.