In my php program, when user clicks the download link, image(jpg) file will be downloaded. But i need to added a record to the database after download has completed. ie., I need to less Credit Points of that particular user after download has completed. How do i know by the php program whether download is completed. How can i check this? kindly reply for this. Thankyou, yasodha.
I'am not sure what exactly do you need... because I know that there is a way to add a record to database when someone click to download something... For example... there sholud be a link on a page.. <a href='page.php?download=34'>download it</a> where 34 should be ID of that picture or something you want to download. And on the "page.php" you do enter in data base record that someone (or that registered user) downloaded file with ID 34 ... But I'am not sure that PHP can give you information WHEN someting is DOWNLOADED...
How are you outputting the file? I usually do it in chunks of X bytes, after the loop you add the query to update download complete. fopen file while_read_file { echo binary } update database Peace,
yes, i have done this. i have given update query in download.php. When i click download link, a dialog box appears, whether to Open, Save or Cancel. When i give Cancel also the database is updated. If i click Cancel database should not update. i have tried this code in many other places in the same program, but no use. here is the code i have given..... if ($file) { while(!feof($file)) { print(fread($file, 1024*8)); flush(); if (connection_status()!=0) { @fclose($file); die(); } } $uname=$_SESSION['uname']; $query="select * from user_det where UserName='$uname' "; $qry_result = mysql_query($query) or die(mysql_error()); if (($row=mysql_fetch_array($qry_result))>0) { $cp=$row[CrPoints]-1; $query="update user_det set CrPoints='$cp' where UserName='$uname'"; $qry_result = mysql_query($query) or die(mysql_error()); } }