the file is written out of the web server and then read with readfile and available for download
##backup.php"##
<?php
session_start();
$usuario_backup = $_SESSION[USER_NAME];
$file = $usuario_backup.".".sql;
system("mysqldump.exe --user $usuario_backup -pUser_Password_Database --databases $usuario_backup > d:\bkp/$usuario_backup.sql");
header('Content-Description: File Transfer');
header('Content-Type: application/sql');
header('Content-Disposition: attachment; filename='.basename($file));
header('Content-Transfer-Encoding: text');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: ' . filesize($file));
ob_clean();
flush();
readfile(\'d:\bkp\\'\.$file);
?>
as I am in windows, I had to copy the mysqldump.exe to the folder with the backup.php
It is assumed that was logged in a separate table by putting the username in the session.
assumed to have a bench in mysql with the same name used in the User login and User in mysql with the same name of the bank and with the necessary privileges on it.