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 (14)
- csharp curl (7)
- 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)
- database and curl (3)
- get images using curl php (2)
- storing data in database using javascript (2)
- how to get data from remote database from curl (2)
- database curl (2)
- php curl remote database (2)
- database connection using curl (2)
- curl vs remote database connection php (2)
- search a todaybirthday in mysql (2)
- curl to database (2)
- http post to database (2)
- how to start a remote script with php curl (2)
- insert data into table using curl (2)
- insert into db using curl script in php (2)
- conditioners inurl:/guestbook php?new_message= (2)
- post data in mysql using curl in php (2)
- C sharp curl (2)
- PHP curl update remote database (2)
- php insert data on remote database (1)
- php insert data to remote database (1)
- php post curl from database blob (1)
- php insert data in mysql database using curl (1)
- php get data from remote database (1)
- php curl store cookie data in mysql (1)
- php curl to update database on remote site (1)
- php curl to database complete script (1)
- PHP CURL TO MYSQL DATABASE $query = INSERT INTO (1)
- read remote url and save in db using curl (1)
- php execute remote code with curl (1)
- php extracting data from a remote database (1)
- php database connection curl (1)
- PHP CURL TO MYSQL DATABASE $query = INSERT INTO (1) (1)
You will also be interested in ,
- Enabling curl on XAMPP for Windows
- Post Data To Another Website Using cURL In PHP
- Login to yahoo using cUrl in php
- Simple Visitor Counter Using php
- Set xampp:- Apache Mysql Filezilla Mercury Tomcat as a windows service and get xampp to start automatically on boot up
- How to use Namespaces in php 5.3 ?
- Get DNS Record using PHP
- Find out which mode php is running CGI or DSO mode
- Find the string and then the line number using php from text file
- Secure PHP Scripts


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