BLiZZaRD
07-30-2006, 12:41 PM
Not sure really what I am asking here... I will try to explain it best I can.
I am sure my not even knowing what exactly I want is why I can figure this out.
I have a php script that, when run, will make a MySQL dump of a database of mine.
What I want is for this script:
<?php
$emailaddress = "name@site.com";
$host="XXXXXXX"; // database host
$dbuser="XXXXXXX"; // database user name
$dbpswd="XXXXXX"; // database password
$mysqldb="XXXXXX"; // name of database
$filename = "/path/to/backup" . date("d") . ".sql";
if ( file_exists($filename) ) unlink($filename);
system("mysqldump --user=$dbuser --password=$dbpswd --host=$host $mysqldb > $filename",$result);
$size = filesize($filename);
switch ($size) {
case ($size>=1048576): $size = round($size/1048576) . " MB"; break;
case ($size>=1024); $size = round($size/1024) . " KB"; break;
default: $size = $size . " bytes"; break;
}
$message = "The database backup for " . $mysqldb . " has been run.\n\n";
$message .= "The return code was: " . $result . "\n\n";
$message .= "The file path is: " . $filename . "\n\n";
$message .= "Size of the backup: " . $size . "\n\n";
$message .= "Server time of the backup: " . date(" F d h:ia") . "\n\n";
mail($emailaddress, "Database Backup Message" , $message, "From: Website <>");
?>
to be on a page... let's call it dump.php
I want to browse to setup.php, once I am there I want to have input boxes.
One for $email
One for $filename (kind of.. see below)
and a submit button.
Now when I put in BLiZZard@BLiZZ.com
and BLiZZ
then click submit,
I want dump.php to get those 2 vars and replace them in the script.
HOWEVER... the $filename can't really change, as it is the path, but the "backup" part can.
So using the above example, this line:
$filename = "/path/to/backup" . date("d") . ".sql";
Will end up looking like this:
$filename = "/path/to/BLiZZ" . date("d") . ".sql";
also $email would change to BLiZZaRD@BLiZZ.com
I am thinking I need $filename line to instead of saying /backup I need a new variable like /$name...
Am I even making sense?
I am sure my not even knowing what exactly I want is why I can figure this out.
I have a php script that, when run, will make a MySQL dump of a database of mine.
What I want is for this script:
<?php
$emailaddress = "name@site.com";
$host="XXXXXXX"; // database host
$dbuser="XXXXXXX"; // database user name
$dbpswd="XXXXXX"; // database password
$mysqldb="XXXXXX"; // name of database
$filename = "/path/to/backup" . date("d") . ".sql";
if ( file_exists($filename) ) unlink($filename);
system("mysqldump --user=$dbuser --password=$dbpswd --host=$host $mysqldb > $filename",$result);
$size = filesize($filename);
switch ($size) {
case ($size>=1048576): $size = round($size/1048576) . " MB"; break;
case ($size>=1024); $size = round($size/1024) . " KB"; break;
default: $size = $size . " bytes"; break;
}
$message = "The database backup for " . $mysqldb . " has been run.\n\n";
$message .= "The return code was: " . $result . "\n\n";
$message .= "The file path is: " . $filename . "\n\n";
$message .= "Size of the backup: " . $size . "\n\n";
$message .= "Server time of the backup: " . date(" F d h:ia") . "\n\n";
mail($emailaddress, "Database Backup Message" , $message, "From: Website <>");
?>
to be on a page... let's call it dump.php
I want to browse to setup.php, once I am there I want to have input boxes.
One for $email
One for $filename (kind of.. see below)
and a submit button.
Now when I put in BLiZZard@BLiZZ.com
and BLiZZ
then click submit,
I want dump.php to get those 2 vars and replace them in the script.
HOWEVER... the $filename can't really change, as it is the path, but the "backup" part can.
So using the above example, this line:
$filename = "/path/to/backup" . date("d") . ".sql";
Will end up looking like this:
$filename = "/path/to/BLiZZ" . date("d") . ".sql";
also $email would change to BLiZZaRD@BLiZZ.com
I am thinking I need $filename line to instead of saying /backup I need a new variable like /$name...
Am I even making sense?