Home  >  Article  >  Backend Development  >  Programmatic submission form

Programmatic submission form

巴扎黑
巴扎黑Original
2016-12-01 10:51:281016browse

char accept[] = "Accept: */*";
char frmdata[] = "param1=str1¶m2=str2¶m3=str3";
HINTERNET hSession = InternetOpen("MyAgent", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
HINTERNET hConnect = InternetConnect(hSession, "www.target.com", INTERNET_DEFAULT_HTTP_PORT, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 1);
HINTERNET hRequest = HttpOpenRequest(hConnect, "POST", "filename.php", NULL, NULL, (LPCSTR *)&accept, INTERNET_FLAG_NO_COOKIES , 1);
HttpSendRequest(hRequest, "Content-Type: application/x-www-form-urlencoded", -1, (LPVOID)frmdata, sizeof(frmdata));
InternetCloseHandle(hRequest );
InternetCloseHandle(hConnect);
InternetCloseHandle(hSession);

Explanation:

frmdata is form data, where the form parameters are separated by &;

The second parameter of HttpOpenRequest uses POST, which means submitting the form.


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn