Ben_Phillips
December 13th, 2004, 05:50 PM
I am trying to figure out how to do automated logins on webpages, but I have no idea of how to format a POST request to a server. Specifically I am trying to log in to a simple php webpage with only two form fields titled "username" and "password". Its php page for handling the login is '/login.php'. I need to login to this webpage and retrieve the html for some pages. I know how to get the html for pages using a GET request, but I need to know how to format a POST request. Any help here would be greatly appreciated!
I am using the CInternetSession, CHttpConnection, and CHttpFile to do the server communications. I open up a connection to the server with the GetHttpConnection method of the CInternetSession class and then with my CHttpConnection class I use OpenRequest with the first argument as CHttpConnection::HTTP_VERB_POST, the second as "/login.php", and the rest are insignificant (I hope, *EDIT* for the request flags I use INTERNET_FLAG_EXISTING_CONNECT and INTERNET_FLAG_NO_AUTO_REDIRECT ). I am stuck as to what to do with the headers to format the POST.
Thank you in advance.
- Ben Phillips
I am using the CInternetSession, CHttpConnection, and CHttpFile to do the server communications. I open up a connection to the server with the GetHttpConnection method of the CInternetSession class and then with my CHttpConnection class I use OpenRequest with the first argument as CHttpConnection::HTTP_VERB_POST, the second as "/login.php", and the rest are insignificant (I hope, *EDIT* for the request flags I use INTERNET_FLAG_EXISTING_CONNECT and INTERNET_FLAG_NO_AUTO_REDIRECT ). I am stuck as to what to do with the headers to format the POST.
Thank you in advance.
- Ben Phillips