Im trying to send an array using curl.
I am brand new to curl.
How do I populate my array depending on form data?
I need full_name to pull data from the form. So email goes into email and company goes into company.
Here is where I am right now. I think urlencode($_POST['company']), is the wrong start.
<?php
$url = '#';
$data = array(
'full_name' => urlencode($_POST['first_name']),
'company_name' => urlencode($_POST['company']),
'email' => urlencode($_POST['email']),
'free_trial' => urlencode($_POST['last_name']),
'quota' => urlencode($_POST['last_name']),
'wanaccel' => 'No',
'contract' => urlencode($_POST['last_name']),
);
$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);
?>