Jump to content

Using CURL to post data


paddy_fields

Recommended Posts

I've made a CMS with a form that allows jobs to be posted to my database. I also want the job to be posted to 'reed.co.uk', a UK job board simultaneously.

 

In their documentation the only way to post 'automatically' ie not via their site is by sending a POST request to their specified URL

 

I want this to happen via the php processing MY form into MY database, and not have the user have to fill out another form (the reed version) with the same data.

 

From a blitz of Google it looks like CURL can be used to automatically send POST data, like in the code below;

<?php
$ch = curl_init();
$data = array('name' => 'phpnoob', 'address' => 'somewhere');

curl_setopt($ch, CURLOPT_URL, 'http://localhost/url/to/your/php/form.php'); // use the URL that shows up in your <form action="...url..."> tag
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);

curl_exec($ch);
?> 

Is this the right solution for this?

 

I could have the CURL code on the same PHP page that inserts the data into my own database right?

 

Any pointers would be very much appreciated, I've never worked with CURL before., Before I get down to writing it it would be nice to know I'm on the right track!

 

For reference the Reed instructions are here: http://www.reed.co.uk/recruiter/uploadreference

Link to comment
https://forums.phpfreaks.com/topic/287331-using-curl-to-post-data/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.