John Davidson

c++ - Issue Sending Post Data To PhP

0 comments
Message:


The Library Im Using: https://github.com/Code-Building/requests


PHP


if (register($_GET['username'], $_GET['password'], $_GET['hwid'])) { ... }


C++


    http::request* result = http::post("https://xxx/api/handle.php?t=", data);

printf("%s", result->text.c_str());

I would like to add running this on a local server works just fine, having issues with livenet since thats what our teacher wants.
Also the issue is sending the post data. Manually entering post data / sending with fiddler work just fine. Any Ideas?


(Ive also used $_POST didnt work aswell)



My Answer:
"https://example.com/register.php", "username=myusername&password=mypassword&hwid=myhwid");_

The issue with sending post data to PHP in this code snippet is that it is using the GET method instead of the POST method. To send data using the POST method, you should use the http::post function instead of http::request. Additionally, you should pass the data as a string in the format "key1=value1&key2=value2" to the http::post function.

Rate this post

3 of 5 based on 7036 votes

Comments




© 2024 Hayatsk.info - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us