Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8346045
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T06:52:55+00:00 2026-06-09T06:52:55+00:00

How can I save data from one site to another sites database? I need

  • 0

How can I save data from one site to another sites database? I need to make a form which saves data to an external database. I tried using fopen but I don’t think this is the correct way to do it:

$externalsave = fopen('http://onewebsite.com/folder/this_page_INSERTS_INTO_DB.php?datavalue1='.$data1.'&datavalue2='.$data2, 'r');
$data = '';
while(!feof($externalsave)) 
   $data .= fread($externalsave, 4092); 
fclose($externalsave); 

echo $data;

Does someone know how I can save values inserted in a form on one website, in an external database?

I’m using an Apache server, and the code above works fine, I just don’t trust it. Or can I?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T06:52:56+00:00Added an answer on June 9, 2026 at 6:52 am

    There is 3 main solutions :

    1. Remote action

    The easiest one is to simply point your form on the remote server. For exemple :

    <form method="post" action="http://myothersite.com/myphpscript.php">
    </form>
    

    And in myphpscript.php simply handle the form like you will in localhost.

    2. Proxy action (require the allow_url_fopen directive to be enabled)

    You could also point your form on a php script on the same server which gonna send your data on the other server.
    This solution can be usefull to bypass security like csrf token :

    <form method="post" action="proxy.php"></form>
    

    proxy.php :

    $postdata = http_build_query($_POST); //Need some filtering !!!
    
    $opts = array('http' =>
        array(
            'method'  => 'POST',
            'header'  => 'Content-type: application/x-www-form-urlencoded',
            'content' => $postdata
        )
    );
    
    $context  = stream_context_create($opts);
    $result = file_get_contents('http://myotherserver.com/submit.php', false, $context);
    

    No need of curl here 😉

    3. Remote database

    Finally you can use a database with remote access and simply connect to the database with its remote host like :

    $mysqli = new mysqli('mydbHost.com', 'my_user', 'my_password', 'my_db');
    

    Unfortunately this solution is rarely allowed because it could represent a big security risk (anyone in the world can try to connect to the database).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to copy data from one database to another with EF. E.g. I
I need to transfer data from one DB to another. The destination DB contains
How can I save data from an Excel sheet to .RData file in R?
I try to create a form that can save a person's form data so
If I wanted to save a contact form submission to the database, how can
I need to open one file, parse it, make http requests and save the
I have a jquery script that collects data from different sites and saves it
I'm able to edit & save data from one Activity(EditActivity.java), but the updated data
Is there a way that i can save data on each step in wizard
I want to setup a table that can: Save the data on the user's

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.