| |
| BOOL CreateForm( |
| |
LPCTSTR lpszAction, |
|
| |
UINT nFormMethod, |
|
| |
UINT nFormType |
|
| ); |
The CreateForm method creates a new form for use with the
other form-related functions.
Parameters
- lpszAction
- A null-terminated string which specifies the name
of the resource that the form data will be submitted to. Typically
this is the name of a script that is executed on the server.
- nFormMethod
- An unsigned integer value which specifies how the form data
will be submitted to the server. This parameter may be one of the
following values:
| Value |
Description |
| HTTP_METHOD_DEFAULT |
The form data should be submitted using the default method,
using the GET command. |
| HTTP_METHOD_GET |
The form data should be submitted using the GET command.
This method should be used when the amount of form data is
relatively small. If the total amount of form data exceeds 2048
bytes, it is recommended that the POST method be used
instead. |
| HTTP_METHOD_POST |
The form data should be submitted using the POST command.
This is the preferred method of submitting larger amounts of
form data. If the total amount of form data exceeds 2048 bytes,
it is recommended that the POST method be used. |
- nFormType
- An unsigned integer value which specifies the type of form and
how the data will be encoded when it is submitted to the server.
This parameter may be one of the following values:
| Value |
Description |
| HTTP_FORM_DEFAULT |
The form data should be submitted using the default
encoding method. |
| HTTP_FORM_ENCODED |
The form data should be submitted as URL encoded values.
This is typically used when the GET method is used to submit
the data to the server. |
| HTTP_FORM_MULTIPART |
The form data should be submitted as multipart form data.
This is typically used when the POST method is used to submit a
file to the server. Note that the script must understand how to
process multipart form data if this form type is
specified. |
Return Value
If the method succeeds, the return value is non-zero. If the
method fails, the return value is zero. To get extended error
information, call GetLastError.
Remarks
The CreateForm method is used to create a new form that
will be populated with values and then submitted to the server for
processing. When the form is no longer needed, it should be destroyed
using the DestroyForm function.
Example
CString strResult;
INT nResult = 0;
pClient->CreateForm(_T("/login.php"), HTTP_METHOD_POST, HTTP_FORM_ENCODED);
pClient->AddField(_T("UserName"), lpszUserName);
pClient->AddField(_T("Password"), lpszPassword);
nResult = pClient->SubmitForm(strResult);
pClient->DestroyForm();
Requirements
Minimum Desktop Platform: Windows 7 Service Pack 1
Minimum Server Platform: Windows Server 2008 R2 Service Pack 1
Header File: cstools12.h
Import Library: cshtpv12.lib
Unicode: Implemented as Unicode and ANSI versions
See Also
|
|