I have a form that creats a json array from user input data.
Array
(
[full_name] => First Name + Last Name
[company_name] => Company Name
[email] => Email
[free_trial] => trial (Yes/No)
[quota] => quota
[contract] => 0 (0/1)
[per_gb] => cost per gb
[per_month] => contract length in months
[wanaccel] => No (Yes/No)
)
I need to send that to a php curl file so that it can be sent to an ip address.
How do I populate the curl data array from that json file?
Here is where I am starting with the curl page.
<?php
$url = '#';
$data = array(
'full_name' => $_POST["full_name"],
'company_name' => $_POST["company_name"],
'email' => $_POST["email"],
'free_trial' => $_POST["free_trial"],
'contract' => $_POST["contract"],
'wanaccel' => 'No',
'per_month' => $_POST["per_month"],
);
$data_string = json_encode($data);
$post = curl_init('localhost');
curl_setopt($post, CURLOPT_VERBOSE, true);
curl_setopt($post, CURLOPT_POST, count($data));
curl_setopt($post, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($post, CURLOPT_RETURNTRANSFER, true);
curl_setopt($post, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13');
curl_setopt($post, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data_string))
);
$result = curl_exec($post);
curl_close($post);
echo "here is the result".$result." |\n";
echo ( $result );
print_r($data);
?>
Any thoughts?
Thanks so much!