now before you tell me this is javascript, please read.. the reason i post in here is because it involves PHP headers...
The PHP Code:
if(isset($_GET['id'])) {
$id = $_GET['id'];
include '../library/include.php';
if (isset($_GET['reset'])) {
$query = "UPDATE artist SET saved='0' WHERE id='$id'";
mysql_query($query);
header("Location:image_download.php"); /* it has updated the row and now refreshes the window .. it will now look like YES [ RESET ] */
}
else {
$query = "UPDATE artist SET saved='1' WHERE id='$id'";
$result = mysql_query($query) or die('Saved row update failed');
$query = "SELECT filename, filetype, filesize, filepath FROM artist WHERE id = '$id'";
$result = mysql_query($query) or die('Error, query failed');
list($filename, $filetype, $filesize, $filePath) = mysql_fetch_array($result);
header("Content-Disposition: attachment; filename=$filename");
header("Content-length: $filesize");
header("Content-type: $filetype");
/* i've tried header("Location:image_download.php"); in here but it just does nothing... and AFTER the readfile command and after the mysql, and i've tried href.location links in the a href... (onClick etc..) */
readfile($filePath);
mysql_close();
exit;
}
}
The HTML Code:
<a href="?id=<?php echo $id;?>">DOWNLOAD</a>
<br /><?php echo $saved; ?> <?php if ($saved == YES) { echo "[ <a href=\"?id=$id&reset\">RESET</a> ]"; } ?>
The Explaination:
Lets say "SAVED" is no, the saved row will show "NO"... if SAVED is yes, it will display "YES [ RESET ]" .. that bit works perfectly...
my problem is with the refresh when i hit DOWNLOAD. it brings up the link download (a file download window) but because of the headers i cant refresh, redirect etc the page because the headers have told it to do the download...
HOW can i do both.. to popup the download window, and either refresh the page during or after the download popup is up...
the refresh will change the "NO" to "YES [ RESET ]"..
if that doesnt make sence, i can post the entire page so you can see what i mean.
Thanks.hope im making sense..
Phill...