How can i transfer data from one website to another in php?

I own 2 websites, example.com and domain.com. I want to securely transfer data from example.com to domain.com. I was looking at this question which is trying to answer my main question of how to send data securely from one website to another. However, the answer's are very old.

I am wondering how I can send do this. I have the below code which basically has the encryption keys saved locally on both websites and encrypts/decrypts data based on that. However, if someone managed to guess the key, they can decrypt all the messages. Is the way I have stated below a secure method to transfer data? Or is there a better way?

function encrypt($key, $data) {
    $encryption_key = base64_decode( $key );
    if ($encryption_key === FALSE) {
        return FALSE;
    }

    $iv = openssl_cipher_iv_length('aes-256-cbc');
    if ($iv === FALSE) {
        return FALSE;
    }

    $iv = openssl_random_pseudo_bytes($iv);
    if ($iv === FALSE) {
        return FALSE;
    }

    $encrypted = openssl_encrypt($data, 'aes-256-cbc', $encryption_key, 0, $iv);
    if ($encrypted === FALSE) {
        return FALSE;
    }

    return base64_encode($encrypted . '::' . $iv);
}

function decrypt($key, $data) {

    $encryption_key = base64_decode( $key );
    if ($encryption_key === FALSE) {
        return FALSE;
    }

    $decoded_data = base64_decode($data);
    if ($decoded_data === FALSE) {
        return FALSE;
    }

    list($encrypted_data, $iv) = array_pad(explode('::', $decoded_data, 2),2,null);

    $decryption = openssl_decrypt($encrypted_data, 'aes-256-cbc', $encryption_key, 0, $iv);
    if ($decryption === FALSE) {
        return FALSE;
    }

    return $decryption;
}

So this is what would be used, and I would send the encrypted data via POST request using cURL to domain.com

// On example.com (aka sending data)
$example_key = 'key_is_123';
$data = "My secret is that I like apples";
$encrypted_msg = encrypt($example_key, $data);

echo("Sending encrypted message:\n$encrypted_msg\n\n");

// Send $encrypted_msg message via a POST request using cURL to domain.com

// On domain.com (aka receiving data)
$domain_key = $example_key;
$decrypted_msg = decrypt($domain_key, $encrypted_msg);

echo("Recieved messaged and decrypted message:\n$decrypted_msg");



Transfer Data from One Page to Another Page in PHP

To transfer data from one web page to another webpage we need Html form and using action="" we transfer form data on another page.

Using $_POST['field_name'] we receive form data on another page in PHP if method is post in case of get method use $_GET['field_name'];.

index.html

Html page

<form action="display.php" method="post" id="nameform">
First Name: <input type="text" name="fname"></br>
Last Name: <input type="text" name="lname"></br>
<button type="submit" form="nameform" value="submit">Submit</button>
<button type="reset" value="Reset">Reset</button>
</form>

display.php

Receive form data on other page

<?php

$first_name = $_POST['fname'];
$last_name = $_POST['lname'];

echo $first_name;
echo $last_name;

?>

When you fill html form all data will be transfer from index.php to display.php



Buy This Ad Space @$20 per Month, Ad Size 600X200 Contact on: or 9999595223

How can i transfer data from one website to another in php?

  • How can I transfer data from one PHP page to another?
  • How does JavaScript send data between HTML pages?
  • How can get ID from one page to another in PHP?
  • How to transfer data from one page to another page in PHP?
  • How to pass form variables to another page in PHP?

How to pass form variables from one page to other page in PHP ?

  1. Code 1: Start your localhost server like Apache, etc.
  2. Output: It will open your form like this, asked information will be passed to the PHP page linked with the form (action=”form2.
  3. Code 2: Repeat the process of saving the file as explained above.

How do I pass data between two PHP pages?

The session is an activity period where visitor’s data is stored and passed to following pages. We tell the PHP interpreter to start a session by defining session_start() at the beginning of every PHP file we want session to happen. Then we access the session variables using the $_SESSION[‘variable-name’] method.

How to send data to PHP file using post?

In javascript i want to know how to send data to php file using post method. I have tried diffewrent method. But i didn’t get any output so please help me. My code is shown below.

How does JavaScript send data between HTML pages?

I am sending the data through the query parameters like http://localhost/project/index.html?status=exist. The problem with this method is that data remains in the URL. Is there any other method to send the data across HTML pages using JavaScript or jquery.

How to post data from one page to another in JavaScript?

The following is a simple example of how to submit data from one HTML page to another using the POST method from Javascript. Normally, if data needs to be sent from one HTML page to another, it is done by appending the information to the query parameter of the the URL in the familiar “name=value” format. e.g.

How to pass data from JavaScript to PHP?

You can pass data from PHP to javascript but the only way to get data from javascript to PHP is via AJAX. The reason for that is you can build a valid javascript through PHP but to get data to PHP you will need to get PHP running again, and since PHP only runs to process the output, you will need a page reload or an asynchronous query.

How can get ID from one page to another in PHP?

$id = $_GET[“myid”]; If you look at above code you will get idea how we are accessing the first page variable to second page through $_GET variable method to share the information from one page to another page and storing them in $id variable that we have created.

Which of the following is used to store and pass information from one page to in PHP?

PHP Session
PHP session is used to store and pass information from one page to another temporarily (until user close the website).

How can I get ID in PHP?

php include ‘db. php’; if(isset($_GET[‘id’])){ $id = $_GET[‘id’]; $sql = $con->prepare(“select * from alert_users_account where id=?”); $sql->bind_param(‘i’,$id); $sql->execute(); $result = $sql->get_result(); $row = $result->fetch_assoc(); echo $row[‘id’]; }else{ echo ‘error’; } ?>

How to transfer data from one page to another page in PHP?

Transfer Data from One Page to Another Page in PHP To transfer data from one web page to another webpage we need Html form and using action=”” we transfer form data on another page. Using $_POST [‘field_name’] we receive form data on another page in PHP if method is post in case of get method use $_GET [‘field_name’];.

How to copy one mysql table to another using PHP?

You can copy one table to another using an MYSQL query and PHP script. if you are working on a PHP project and you want to copy a table data to another using MYSQL and PHP then you have done it by myself insert and select query. Think about the update operation in php. How we can get the data from the database user id.

How to redirect to another page in PHP?

PHP provides a simple and clean way to redirect your visitors to another page that can be either relative or can be cross domain. Here is a simple redirection script that will redirect to thank you page if the comment is submitted successfully.

How to pass form variables to another page in PHP?

In the next step, submitted information will be stored in the session array. Code 2: Repeat the process of saving the file as explained above. Use the file name ‘form2.php’. When you will click ‘Next’ on form1.php page. This page will be asking the college/company name, city, state user is in, and the course he/she is applying for.

How do I transfer data between two websites?

Don't fret; we'll walk you through the necessary steps to make the process as simple as possible..
Backup Your Website. ... .
Check Your DNS Settings. ... .
Transfer Files to a New Domain. ... .
Make Sure to Redirect Pages. ... .
Fix Any Broken Links. ... .
Let Google Know About the Site Transfer. ... .
Check Your Site..

How to send data to another page in PHP?

Transfer Data from One Page to Another Page in PHP To transfer data from one web page to another webpage we need Html form and using action="" we transfer form data on another page. Using $_POST['field_name'] we receive form data on another page in PHP if method is post in case of get method use $_GET['field_name'];.