Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Posting to a form

Posting to a form

Scheduled Pinned Locked Moved C / C++ / MFC
htmlcomquestion
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    Christian Skovdal Andersen
    wrote on last edited by
    #1

    Hi, I would like to post a

    . I think I have found the right way to do it, but it just will not work. It only works if I want to post an URL (like http://www.foo.com/res.asp&name=bart), but not if it is alot of text. Below is some sample code, that I would like to use for sending an SMS message programatically.

    try{
    	CString strHeaders = \_T("Content-Type: application/x-www-form-urlencoded");
    	CString strFormData = \_T("afsender=boetos&modtager=5555554578&besked=this+is+a+test");
    	
    	CInternetSession session;
    	CHttpConnection\* pConnection = session.GetHttpConnection(\_T("212.112.128.11"));
    	if (pConnection)
    	{
    		CHttpFile\* pFile = pConnection->OpenRequest(CHttpConnection::HTTP\_VERB\_POST, \_T("/res.asp"));
    		ASSERT(pFile);
    		BOOL result = pFile->SendRequest(strHeaders, (LPVOID)(LPCTSTR)strFormData, strFormData.GetLength());
    		if (result)
    		{
    			CString strData;
    			CString strBuff;
    			while (pFile->ReadString(strBuff))
    			{
    				strData += strBuff;
    				strBuff.Empty();
    			}
    			
    			//AfxMessageBox(strData);
    			FILE \*f=fopen("res.html", "w");
    			if (f)
    			{
    				fprintf(f, strData);
    				fclose(f);
    			}
    
    			AfxMessageBox("Done!");
    
    			
    			pFile->Close();
    			delete pFile;
    		}
    	}
    	pConnection->Close();
    	delete pConnection;
    	
    }
    catch (CInternetException\* pEx)
    {
    	// catch errors from WinINet
    	pEx->ReportError();
    	pEx->Delete();
    	return;
    }
    

    Can anybody tell me what goes wrong? Regards, Christian Skovdal Andersen

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups