Skip to content
PHP Logo

What is the best way to create a button in PHP that triggers the data transfer process between databases?

To create a button in PHP that triggers the data transfer process between databases, you can use a form with a submit button. When the button is clicked, it can call a PHP script that connects to the source database, retrieves the data, and inserts it into the destination database.

php
<form method="post" action="transfer_data.php">
    <button type="submit" name="transfer_data">Transfer Data</button>
</form>
```

In the `transfer_data.php` script, you can handle the data transfer process like this:

```php
<?php
if(isset($_POST['transfer_data'])) {
    // Connect to the source database
    // Retrieve data from the source database
    // Connect to the destination database
    // Insert data into the destination database
    echo "Data transfer successful!";
}
?>