Jump to content

offer dump file of db with php


rubing

Recommended Posts

good evening folks.

 

I have a website, which logs a lot of client info to a mysql database.  I want to offer these logs to the client as a file download (csv, sql, whatever...)

 

so, I know its easy to create a dump file of a database with the mysql dump command.  But I am confused as to how to let a customer download a dump of their customer data.

 

I guess basically I am asking how do I get php to present a file for download to the client???

Link to comment
https://forums.phpfreaks.com/topic/123077-offer-dump-file-of-db-with-php/
Share on other sites

try this

// We'll be outputting a PDF
header('Content-type: text/plain');

// It will be called downloaded.pdf
header('Content-Disposition: attachment; filename="database.sql"');

echo `mysqldump -ppassword -uusername database`;

 

Scott.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.