If you want to restore your database with all tables and their data using the code of PHP this will helps you.
Here is the example of Database Restore PHP Script :
<?php
if(isset($_POST['submit'])) //Set Click event on form load
{
$host = "database_host_name";
$db_user = "database_user_name";
$db_pwd = "database_password";
$db_name = "database_name";
error_reporting(0);
ini_set('memory_limit','128M');
$db = mysqli_connect($host,$db_user,$db_pwd,$db_name);
//File name you want to upload.
$filename = $_FILES["filemainname"]["name"];
$fp = fopen($filename, 'r' );
$fetchData = fread($fp, filesize($filename));
$sqlInfo = explode(";\n", $fetchData);
foreach ($sqlInfo AS $sqlData )
{
$datad = mysqli_query($db,$sqlData);
}
echo 'Done';
}
?>
<form action="index.php" method="post" enctype="multipart/form-data">
<label for="file">Filename:</label>
<input type="file" name="filemainname" id="filemainname"><br>
<input type="submit" name="submit" value="Submit">
</form>
No comments:
Post a Comment