Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7561299
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T13:07:43+00:00 2026-05-30T13:07:43+00:00

I try to make a post request with php and curl. Here is my

  • 0

I try to make a post request with php and curl. Here is my code

//PHP 5.3.5 and curl: 7.18.2
$ch = curl_init();
if(!empty($save_cookie)){
    curl_setopt($ch, CURLOPT_COOKIEJAR, $save_cookie);
    curl_setopt($ch, CURLOPT_COOKIEFILE, $save_cookie);
}else{
    curl_setopt($ch, CURLOPT_COOKIE, $cookie);
}

curl_setopt($ch, CURLOPT_REFERER, $referer);
curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);
curl_setopt($ch, CURLOPT_URL, 'http://localhost/post.php');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $pars);
curl_setopt($ch, CURLOPT_HEADER, $header);
curl_setopt($ch, CURLOPT_NOBODY, !$body);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

$postResult = curl_exec($ch);

if (curl_errno($ch)) {
    return false;
}

curl_close($ch);
return $postResult;

In http://localhost/post.php, I write

print_r($_SERVER);

The result return of curl is always

[REQUEST_METHOD] => GET
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T13:07:45+00:00Added an answer on May 30, 2026 at 1:07 pm

    Remove the CURLOPT_NOBODY option and it will work. Or place it above the CURLOPT_POST line.

    I think I have encountered this once, when trying to get just the header of a response. Setting

    curl_setopt($ch, CURLOPT_NOBODY, true);
    

    effectively instructs curl to issue a HEAD request, which is not a POST request. I think there is no way to just get the header from a POST (and just drop the connection after receiving the header). As a side effect, setting CURLOPT_NOBODY to false sets the request type to GET…

    Do you really need the CURLOPT_NOBODY flag?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Did anyone try to make access to api.php?action=parse&text= page with the POST request? on
I try to make a registration form. When user post the fields, i check
What will be the code when I try to make a combo box read
I need to make an HTTP POST request from outside the browser, but the
Is there a way to make an $.ajax POST request: without requiring a response
I could not make a post request from my android app, there must be
For the last two hours i've been trying to make a POST request to
Whenever I try and make any Twitter request, my application always hangs. This does
I'll try to make this as straight forward as possible. Currently our team has
When I try to make a very large boolean array using Java, such as:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.