note 111704 rejected from faq by aharvey
| From: | aharvey@php.net | Date: | Tue, 19 Mar 2013 04:30:59 +0000 |
| Subject: | note 111704 rejected from faq by aharvey | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-194120@lists.php.net to get a copy of this message | ||
Note Submitter: shashank dot malikk at gmail dot com
----
someone help me about the following, i have this PHP code,
i want a webpage where i can enter values is it possible directly through this PHP code or do i have
to create a HTML form code and then link it with this PHP code ?
i tried to link it with the HTML form but the values i'm entering inside HTML those values are
not coming into this PHP code.
<?php
$post_data['key'] = 'your key here';
$post_data['firstname'] = 'first name here';
$post_data['lastname'] = 'last name here';
$post_data['address'] = 'address here';
foreach ( $post_data as $key => $value)
{
$post_items[] = $key . '=' . $value;
}
$post_string = implode ('&', $post_items);
$curl_connection = curl_init('https://example.com/api.php');
curl_setopt($curl_connection, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($curl_connection, CURLOPT_USERAGENT, curl_setopt($curl_connection,
CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl_connection, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl_connection, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($curl_connection, CURLOPT_POSTFIELDS, $post_string);
$result = curl_exec($curl_connection);
echo "Transaction Result: " . $result . "<br><br>";
print_r(curl_getinfo($curl_connection));
echo curl_errno($curl_connection) . '-' . curl_error($curl_connection);
curl_close($curl_connection);
?>