how to make a hyperlink to download the upload file and by the same time it updates its database?
For now I can download the file but it doesn't change the file status.
Here is my code
<a href="reports/<?php echo $row['file']; ?>" target="_blank" onclick="return runMyFunction();">Docx</a>
<script type="text/javascript">
Cufon.now();
function runMyFunction() {
<?php
mysql_query("update report_upload set status=1 from report_upload where year='$year' AND area='$area'",$conn);
?>
return true;
}
</script>
try1 .html
<form id='login' action='adminReportDownload.php' method='POST' enctype='multipart/form-data'>
<input type="hidden" value="<?php echo $area;?>" name="yeara">
<input type="hidden" value="<?php echo $year; ?>" name="yeary">
<input type="hidden" value="<?php echo $abc123; ?>" name="abc123">
<input type="submit" name="submit" id="submit" value="Download">
</form>
.php
$a = $_POST['yeara'];
$b = $_POST['yeary'];
$c = $_POST['abc123'];
$file_path = 'reports/'.$c;
$sqlABC = "UPDATE report_upload SET status='1', usedBy='$sesId' where year='$b' AND area='$a' ";
$eviABC = mysql_query( $sqlABC, $conn );
header("location: reports/$c");