0

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

?>

Edited by double_cola

1
Contributor
2
Replies
16
Views
5 Months
Discussion Span
Last Post by double_cola
0

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?

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.