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);

?>

Im sorry I think I am asking the wrong question.

I have a json array being pushed to this curl file.
How do I get the array to populate the data fields in this curl file?

I asked the wrong question. I will start another discussion.
I appologize.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.