I have collected data and created and array :
Array
(
[0] => Array
(
[id] => 1
[name] => Martin
[surname] => test
[email] => martin@gmail.com
[dob] => 2015-02-24
)
[1] => Array
(
[id] => 2
[name] => Kary
[surname] => paulman
[email] => kary@gmail.com
[dob] => 2015-06-26
)
)
I have multiple records in this array.
I want to post each record in the array to www.recieve.com , where it will pass a response of 'true' if post was successful and 'false' if it fails.
I have researched the interent and i dont even know where to start.
So far my code looks like this (this is just for the array)
$query = "SELECT * FROM applicants";
$result = mysql_query($query) or die(mysql_error());
while($row = mysql_fetch_assoc($result)){
$res[] = $row;
}
echo "<pre>"; print_r($res); echo "</pre>";
I have tryed this and it is not working :
//Build my array
$query = "SELECT * FROM applicants";
$result = mysql_query($query) or die(mysql_error());
while($row = mysql_fetch_assoc($result)){
$res[] = $row;
}
//URL to post to
$url = 'https://theurl.com?';
//url-ify the data for the POST
foreach($res as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }
rtrim($fields_string, '&');
$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);