Say I have the following pages:
index.php
<html>
<form action="/make_file" method="get">
<select name="client" style="width: 80%;">
<?php foreach($clients as $client): ?>
<option value="<?=$client;?>"><?=$client;?></option>
<?php endforeach; ?>
</select>
<input type="submit" value="Download Client Info">
</form>
</html>
make_file.php
<?php
$client = $_GET['client'];
//check that client is valid and grab client information from the database
$tmpfname = tempnam(sys_get_temp_dir(), $clientName);
$handle = fopen($tmpfname, "w");
//create a txt file containing information about the client
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="'.basename($tmpfname).'.txt"');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($tmpfname));
readfile($tmpfname);
unlink($tmpfname);
!!! //now here is where I'd like to create a custom message
?>
So in simple terms, I would like a user to be able to choose a client on index.php, then the make_file.php page will create and serve a text file with information about the client. But ideally, after that I would like to send a crafted alert message (via jquery/ajax..) to the user on index.php. The alert message will depend on the client and their information so it cannot be static.
I have tried several methods, but I'm having a problem with the fact that once you set the content-disposition header the whole output is put into the file (which is the expected behaviour) so I don't really know how to send this alert?