php – cURL – can’t get POST response – Education Career Blog

I’m trying a basic thing. I have two files:
curl.php and


$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://localhost/test/test34_curl_post/form.php");
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, array(
    'nabc' => 'fafafa'
$result = curl_exec($ch);
echo $result;


<form action="form.php" method="post">

<input type="hidden" name="nabc" value="abc" />
<input type="submit" name="submit" value="Send" />



 echo '<br />Form sent!'.$_POST'nabc';

what I’m hoping to get is as the result of running curl.php, to see “Form sent!”. It seems as if it wasn’t sent as POST. In firebug (network) there is only one GET request and what I get is the form, nothing sent. Anyone, please help.


You’re not sending 'submit' in your POST data so isset($_POST'submit') will be false. You need to do the following:

curl_setopt($ch, CURLOPT_POSTFIELDS, array(
    'nabc' => 'fafafa',
    'submit' => 'Send' // if you want 'submit' in $_POST you need this

Leave a Comment