getlist.php 797 Bytes
Newer Older
Daniel Messer's avatar
Daniel Messer committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
<?php

include 'creds.php';

$recordID = $_GET['recordID'];
$bin = $_GET['bin'];

$file = "temp/$bin.txt";

// Run query and loop through the column to write the file

$result = mysqli_query($conn,"SELECT * FROM transaction WHERE recordID = '$recordID'");

while($row = mysqli_fetch_array($result))
{
file_put_contents($file, $row['itemlist']);
}

// Offer file for download.

header("Content-Disposition: attachment; filename=$bin.txt");
header("Content-Type: application/octet-stream");
header("Content-Length: ".filesize("temp/$bin.txt"));
header("Pragma: no-cache");
header("Expires: 0");

$fp = fopen("temp/$bin.txt", "r");

print fread($fp, filesize("temp/$bin.txt"));

fclose($fp);


// Close database connection.
mysqli_close($conn);

header( "refresh:5;url=recallbin.php" );

exit();

?>