Before renderring the page store the download url somwhere (in session for example) and generate some unique hash, which later you can use to identify which file should be downloaded:
$SESSION['file_download']['hash'] = md5(time) . '_' . $userId; // lets say it equals to 23afg67_3425
$SESSION['file_download']['file_location'] = 'real/path/to/file';
When renderring show the user following download url:
http://yourdomain.com/download_file.php?hash=23afg67_3425
If user clicks it you send the file to user, but only allow this one time or during the current session. By this I mean that you should create new source file called download_file.php with following content:
if ($_GET['hash'] == $SESSION['file_download']['hash']) {
// send file to user by outputing the file data to browser
$file = $SESSION['file_download']['file_location'];
header('Content-Description: File Transfer')
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.basename($file));
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($file));
readfile($file);
// optionaly reset $SESSION['file_hash'] so that user can not download again during current session, otherwise the download with generated link will be valid until user session expires (user closes the browser)
} else {
// display error message or something
}