I need to export backup of the database using php when I click on the link. I searched so many references and created code. But when I execute this it displays error. Can anyone help me to get the solution? This is my code
<a href="back.php">BACKUP</a>
Back.php
<?php
include('../database.php');
$dbhost = $_SERVER['SERVER_NAME'];
$dbuser = 'root';
$dbpass = '';
$dbname='marketing';
$backup_file = $dbname . date("Y-m-d-H-i-s") . '.gz';
$command = "mysqldump --opt -h $dbhost -u $dbuser -p $dbpass ". "$dbname | gzip > $backup_file";
$sys=system($command);
if($sys)
{
echo "succc";
}
else{
echo "failed";
}
?>