Fadshop.net
A website for better software and better life in Internet!
   MY WEB

   Chinese URLs

   Greeting Creator

   Input Tips Everyday

   Source Code
Java Applet Games
Visit webpage in VC
M3U Music List Editor
Input Tips everyday
Combox in HTML
Self-made Screen Saver
Model of Neural Network
Display Chinese Characters
Mouse in Maze, a classic game in math
Serial Port Communication

Source Code -> Read Web Pages in VC: PUT
 

POST data as a form


GET data

The technical difference between POST and GET is to seperate URL and data. Data is a part of head in HTTP protocal when POSTing, so that there's an extra part: strHeaders = _T("Content-Type: application/x-www-form-urlencoded") You can change this sentence as image, or binary file.

The difference between source code in this page and in last page is signed by Blue color;
strFormData is data waiting for sent, its content:
strFormData =

#ifndef _DEBUG
    strHttpName="http://www.fadshop.net/curl/progsave.asp";
#else
    strHttpName = "http://Mycomputer/fadshop/curl/progsave.asp";
#endif
//    strHttpName = strHttpName + "?" + strFormData;
in GET method

    CInternetSession sess;//Create session
    CHttpFile* fileGet;
    CString strHeaders =
          _T("Content-Type: application/x-www-form-urlencoded");
    CException* e;
    TRY
    {
        fileGet=(CHttpFile*)sess.OpenURL(strHttpName);//Open File
    }
    CATCH_ALL(e)
    {
        TRACE("Err:%d\n", GetLastError());
        fileGet = 0;
    }
    END_CATCH_ALL
    if(fileGet)
    {
        DWORD dwStatus;
        DWORD dwBuffLen = sizeof(dwStatus);
        BOOL bSuccess = fileGet->QueryInfo(
            HTTP_QUERY_STATUS_CODE|HTTP_QUERY_FLAG_NUMBER,
            &dwStatus, &dwBuffLen);
        strGetSentence = "";
        if( bSuccess && dwStatus>= 200 &&dwStatus<300 ) { 
            BOOL result = fileGet->SendRequest(strHeaders,
               (LPVOID)(LPCTSTR)strFormData, strFormData.GetLength());
            while(fileGet->ReadString(strSentence)){
                strGetSentence =  strGetSentence + strSentence + char(13) +
            char(10);
            }//Get and display
            SetDlgItemText(IDC_COMMENT,    strGetSentence); 
            SetDlgItemText(IDC_UPLOADMSG,    "Received, thankyou."); }// if    bSuccess.
            else 
                SetDlgItemText(IDC_UPLOADMSG,        "Error.");
            fileGet->Close();
        delete fileGet;
    }
    else
        SetDlgItemText(IDC_UPLOADMSG, "Net work problem");
    sess.Close();


   Contact Info
  User Support Sales Question Webmaster

Copyright 1998-2002 Fadshop.net, Inc. All rights reserved.