The information isn’t going to be saved on the localhost database — it needs to be stored in a remote database that I cannot connect directly to.I thought about all of the possible solutions for solving this challenge and settled on this flow:
- User will submit the form, as usual.
- In the form processing PHP, I use CURL to execute a POST transmission to a PHP script on the customer’s server.
- The remote script would do a MySQL INSERT query into the customer’s private database.
This solution worked quite well so I thought I’d share it with you. Here’s how you execute a POST using the PHP CURL library.
//extract data from the post
extract($_POST);
//set POST variables
$url = 'http://mydomain.com/postpage.php';
$fields = array(
'lname'=>urlencode($last_name),
'fname'=>urlencode($first_name),
'title'=>urlencode($title),
'company'=>urlencode($institution),
'age'=>urlencode($age),
'email'=>urlencode($email),
'phone'=>urlencode($phone)
);
//url-ify the data for the POST
foreach($fields as $key=>$value)
{ $fields_string .= $key.'='.$value.'&';
}
rtrim($fields_string,'&');
//open connection
$ch = curl_init();
//set the url, number of POST vars, POST data
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_POST,count($fields));
curl_setopt($ch,CURLOPT_POSTFIELDS,$fields_string);
//execute post
$result = curl_exec($ch);
//close connection
curl_close($ch);
Thanks
Incoming search terms:
- curl database (8)
- csharp curl (6)
- php curl database (5)
- how to store data in database using php (4)
- data inurl:/guestbook php?page= (4)
- curl store to database (3)
- store posted data to remote wordpress database (3)
- Execute a HTTP POST Using PHP CURL (3)
- curl vs remote database connection php (2)
- curl to database (2)
- PHP curl update remote database (2)
- get images using curl php (2)
- php curl remote database (2)
- database connection using curl (2)
- database curl (2)
- how to get data from remote database from curl (2)
- storing data in database using javascript (2)
- inserting data from database using curl (2)
- C sharp curl (2)
- conditioners inurl:/guestbook php?new_message= (2)
- http post to database (2)
- post data in mysql using curl in php (2)
- insert into db using curl script in php (2)
- insert data into table using curl (2)
- php curl for accessing data in a database (1)
- php curl post url data database (1)
- insert data into database by curl (1)
- php curl set remote cookie (1)
- php curl store cookie data in mysql (1)
- php curl to database complete script (1)
- php insert data in mysql database using curl (1)
- php extracting data from a remote database (1)
- php execute remote code with curl (1)
- php database connection curl (1)
- posting data to database using javascript (1)
- PHP CURL TO MYSQL DATABASE $query = INSERT INTO (1) (1)
- insert data into remote database>php>xampp>mysql (1)
- PHP CURL TO MYSQL DATABASE $query = INSERT INTO (1)
- insert data in remote database from another server in php (1)
- php curl post example to access remote database (1)
You will also be interested in ,
- Login to yahoo using cUrl in php
- Post Data To Another Website Using cURL In PHP
- Enabling curl on XAMPP for Windows
- Fix Too many connections mysql_connect
- Appending string using php to a text file
- Get filename and file extension using php
- Ajax Page With PHP
- ScriptAlias and Alias in httpd.conf at a glance
- Get Method and Array Manipulation In Symfony
- Mysql backup via cron using php and email the file

Hi, interesting post. I have been wondering about this issue,so thanks for sharing. I will definitely be coming back to your site.