Jump to content

Using CURL to post data


paddy_fields
Go to solution Solved by trq,

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

Edited by paddyfields
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.