How to POST form variables???

I want to make a client app that posts information to specific web sites cgi-scripts.  CHttpConnection supports a POST action but I cannot find anyother infor on how to POST data in a way that a CGI script would expect form data.



    CInternetSession is(_T("HTTPGET"));
    CHttpConnection *pHC = NULL;
    CHttpFile *pHF = NULL;
    try
    {
        pHC = is.GetHttpConnection(_T(Server));
        pHF = pHC->OpenRequest(_T(Token), _T(Request), NULL, 0,
                               NULL, NULL, 0);
LucidityAsked:
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.

jhanceCommented:
Just use the SendRequest() method to send the POST data along to the server:

try
    {
        pHC = is.GetHttpConnection(_T(Server));
        pHF = pHC->OpenRequest(_T(Token), _T(Request), NULL,0,NULL,NULL, 0);

pHF->SendRequest(NULL, 0, "item=item_val", strlen("item=item_val"));
}
0
chensuCommented:
That won't work. You need to send the "Content-Type: application/x-www-form-urlencoded" header. See

HOWTO: Simulate a Form POST Request Using WinInet
http://support.microsoft.com/support/kb/articles/Q165/2/98.ASP
0
mikeblasCommented:
> That won't work.

Maybe it will, maybe it won't. Some parsesrs require that header and some don't. Some require other headers, or even a cookie.

..B ekiM
0
LucidityAuthor Commented:
chensus worked out great, answer again and I will give you the points.

thanks
0
chensuCommented:
Thank you.
0

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
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
System Programming

From novice to tech pro — start learning today.