'Send data with libcurl to .php in c++

I use libcurl to send request to my site for fetching some info.

But I don't know how to get data from user (c++) and send that to .php file.

It's my c++ source which get name from user :

std::string userUname;
        std::cout << "[?] Enter Your Username: ";
        std::cin >> userUname;
        CURL* curl;
        CURLcode res;
        std::string readBuffer;
        curl = curl_easy_init();
        if (curl) {
            const char* testlevi = "http://example.com/a.php";
             curl_easy_setopt(curl, CURLOPT_URL, testlevi);
            curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback);
            curl_easy_setopt(curl, CURLOPT_WRITEDATA, &readBuffer);
            res = curl_easy_perform(curl);
            curl_easy_cleanup(curl);
            std::cout << readBuffer << std::endl;
        }

And thats my php file which gets username , and will echo:

<?php
$name = $_GET['name'];
if($name == "Jason"){
echo "Welcome Jason.";
}else{
echo "Username is wrong.";
}
?>

I just don't know how to send userUname to .php file($_GET['name'])



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source