Lucidity
asked on
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(Se rver));
pHF = pHC->OpenRequest(_T(Token) , _T(Request), NULL, 0,
NULL, NULL, 0);
CInternetSession is(_T("HTTPGET"));
CHttpConnection *pHC = NULL;
CHttpFile *pHF = NULL;
try
{
pHC = is.GetHttpConnection(_T(Se
pHF = pHC->OpenRequest(_T(Token)
NULL, NULL, 0);
That won't work. You need to send the "Content-Type: application/x-www-form-url encoded" header. See
HOWTO: Simulate a Form POST Request Using WinInet
http://support.microsoft.com/support/kb/articles/Q165/2/98.ASP
HOWTO: Simulate a Form POST Request Using WinInet
http://support.microsoft.com/support/kb/articles/Q165/2/98.ASP
> 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
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
ASKER
chensus worked out great, answer again and I will give you the points.
thanks
thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
try
{
pHC = is.GetHttpConnection(_T(Se
pHF = pHC->OpenRequest(_T(Token)
pHF->SendRequest(NULL, 0, "item=item_val", strlen("item=item_val"));
}