Connect to PHP website, and pass params

I have a string, which I'd like to pass to a PHP webpage, in the form of either POST or GET data (whichever one is easiest).


Or whatever..

So that my PHP script can then parse the data, and store it on my web server.

Any ideas?

LVL 25
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

InteractiveMindAuthor Commented:
winsock, right?
I'd recommend using a library like libcurl for posting data:

InteractiveMindAuthor Commented:
Any examples of use?
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

There are tutorials on the site for the basic usage of curl, but if you want a sample on how to post data:

int VFinder::Login(){
        string field;
        string battle("");
                        ostringstream converter;
                        converter << m_srank;

                curl_easy_setopt(m_handle, CURLOPT_URL, "");
                curl_easy_setopt(m_handle, CURLOPT_WRITEFUNCTION, VFinder::store);
                curl_easy_setopt(m_handle, CURLOPT_COOKIEJAR, "cookie.txt");
                curl_easy_setopt(m_handle, CURLOPT_POST, true);
                curl_easy_setopt(m_handle, CURLOPT_POSTFIELDS, field.c_str());
                curl_easy_setopt(m_handle, CURLOPT_POSTFIELDSIZE, field.size());
                m_login = true;

        curl_easy_setopt(m_handle, CURLOPT_POST, false);
        curl_easy_setopt(m_handle, CURLOPT_URL, battle.c_str());
        return 0;

Feeling lazy right now :P so i just copy pasted code from my application that i made


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
InteractiveMindAuthor Commented:
Right, I found a POST example:

#include <stdio.h>
#include <curl/curl.h>

int main(void)
  CURL *curl;
  CURLcode res;

  char *postthis="moo mooo moo moo";

  curl = curl_easy_init();
  if(curl) {
    curl_easy_setopt(curl, CURLOPT_URL, "");
    curl_easy_setopt(curl, CURLOPT_POSTFIELDS, postthis);

    /* if we don't provide POSTFIELDSIZE, libcurl will strlen() by
       itself */
    curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, strlen(postthis));

    res = curl_easy_perform(curl);

    /* always cleanup */
  return 0;

And I've copied the curl/.. lib into Dev-C++'s include folder, and have pointed my the directories within my Compiler Options to it, but am getting linker errors:

Compiler: Default compiler
Executing  g++.exe...
g++.exe "C:\Documents and Settings\rob\Desktop\KL\post.cpp" -o "C:\Documents and Settings\rob\Desktop\KL\post.exe"    -I"C:\Program Files\Dev-Cpp\include\c++\3.3.1"  -I"C:\Program Files\Dev-Cpp\include\c++\3.3.1\mingw32"  -I"C:\Program Files\Dev-Cpp\include\c++\3.3.1\backward"  -I"C:\Program Files\Dev-Cpp\lib\gcc-lib\mingw32\3.3.1\include"  -I"C:\Program Files\Dev-Cpp\include"  -I"C:\Program Files\Java\jdk1.5.0_01\include"  -I"C:\Program Files\Java\jdk1.5.0_01\include\win32"  -I"C:\Program Files\Dev-Cpp\include\curl"   -L"C:\Program Files\Dev-Cpp\lib" -L"C:\Program Files\Java\jdk1.5.0_01\include" -L"C:\Program Files\Java\jdk1.5.0_01\include\win32" -L"C:\Documents and Settings\rob\Desktop\CpuUsage_src" -L"C:\masm32\lib" -L"C:\Program Files\Dev-Cpp\include\curl"

C:\DOCUME~1\rob\LOCALS~1\Temp/ccCWbaaa.o(.text+0x54):post.cpp: undefined reference to `_imp__curl_easy_init'
C:\DOCUME~1\rob\LOCALS~1\Temp/ccCWbaaa.o(.text+0x7a):post.cpp: undefined reference to `_imp__curl_easy_setopt'
C:\DOCUME~1\rob\LOCALS~1\Temp/ccCWbaaa.o(.text+0x96):post.cpp: undefined reference to `_imp__curl_easy_setopt'
C:\DOCUME~1\rob\LOCALS~1\Temp/ccCWbaaa.o(.text+0xba):post.cpp: undefined reference to `_imp__curl_easy_setopt'
C:\DOCUME~1\rob\LOCALS~1\Temp/ccCWbaaa.o(.text+0xc7):post.cpp: undefined reference to `_imp__curl_easy_perform'
C:\DOCUME~1\rob\LOCALS~1\Temp/ccCWbaaa.o(.text+0xd7):post.cpp: undefined reference to `_imp__curl_easy_cleanup'

Execution terminated
InteractiveMindAuthor Commented:
Hm, bloody hell. I didn't realise... everything within the 'Include' folder within the Libcurl download are mere header files!
InteractiveMindAuthor Commented:
lol <btw, I meant that in a funny and sarcastic manner; not offensive>
I'm not sure what IDE you're using but you have to find a way to make it link to the curl library (you have to add "-lcurl" there).

You can use HTTP functionality.
i.e. u can define your HTTP handlers. e.g.

Add #include <afxinet.h>    // MFC Internet support

HINTERNET     m_hInternetSession;
HINTERNET     m_hHttpConnection;
 HINTERNET     m_hHttpFile;

//Open internet session.
ASSERT(m_hInternetSession == NULL);
m_hInternetSession = ::InternetOpen(AfxGetAppName(), INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);  

You can visit the link to  have brief idea of rest of the functionality: 
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.