A customer recently brought to me a unique challenge. My customer wants information request form data to be collected in a database. Nothing new, right? Well, there is a hurdle — the information isn 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:
1. User will submit the form, as usual.
2. In the form processing PHP, I use CURL to execute a POST transmission to a PHP script on the customer is server.
3. The remote script would do a MySQL INSERT query into the customer is private database.
This solution worked quite well so I thought I would share it with you. Here is how you execute a POST using the PHP CURL library.
view plaincopy to clipboardprint
1. //extract data from the post
2. extract($_POST);
3.
4. //set POST variables
5. $url = http://domain.com/get-post.php;
6. $fields = array(
7. lname=>urlencode($last_name),
8. fname=>urlencode($first_name),
9. itle=>urlencode($title),
10. company=>urlencode($institution),
11. age=>urlencode($age),
12. email=>urlencode($email),
13. phone=>urlencode($phone)
14. );
15.
16. //url-ify the data for the POST
17. foreach($fields as $key=>$value) { $fields_string .= $key.=.$value.&; }
18. rtrim($fields_string,&);
19.
20. //open connection
21. $ch = curl_init();
22.
23. //set the url, number of POST vars, POST data
24. curl_setopt($ch,CURLOPT_URL,$url);
25. curl_setopt($ch,CURLOPT_POST,count($fields));
26. curl_setopt($ch,CURLOPT_POSTFIELDS,$fields_string);
27.
28. //execute post
29. $result = curl_exec($ch);
30.
31. //close connection
32. curl_close($ch);
source: davidwalsh
Related Stuff
-
MooV: Using cutting edge Video phones and Software Video Phones - coupling all that with VoIP and empowering the disabled.
-
Moo Telecom: VoIP communications made easy - Ring anyway with the fun and ease of using a normal phone
-
TagR:Mobile Social Network with Real Time Locations Based services, and Ambience Intelligence, VoiP, IM, Skype, Googletalk, Mapping, Flickr, Events, Calendaring, Scheduling, SecondLife Support
-
ClearSMS : ClearSMS is a Web-based application that lets you send bulk SMS messages to your customers, contacts, or just about anyone.
-
Jajah:jah is a VoIP (Voice over IP) provider, founded by Austrians Roman Scharf and Daniel Mattes in 2005[1]. The Jajah headquarters are located in Mountain View, CA, USA, and Luxembourg. Jajah maintains a development centre in Israel.
-
Skype: It’s free to download and free to call other people on Skype. Skype the number one voice over ip software
- PrivatePhone: a free local phone number with voicemail and messages you can check online or from any phone.
Be the first ... |Add your comment.
Your Comment ...
Name (required)
Email (required, hidden)
Website
