What you are wanting to do is, in theory, not terribly difficult. However, it does require a fairly thorough knowledge of how HTTP works, specifically with how <form action="pagename" method="[GET|POST]"> is handled.
With method="GET", the data that the page is sent to (action="pagename") is URLEncoded and attached to the end of the URL itself. Most search engines use this method and you have horribly long URLs, but they are paste-able/save-able.
With method="POST", the data is sent in the body of the request, hidden from view (prettier for the end user, but not paste-able or save-able). What happens in this case is that the browser (which you will have to emulate in your script) sends back the HTTP headers for the page, followed by a single blank line, followed by the data pairs (controlname=value). Some forms use <input type="HIDDEN" name="SomeName" value="Some value">, and you have to correctly send back that information. Additionally, if the page/site you're working from uses cookies, you'll have to correctly send back the cookie data.
When you initially set up the socket to that site, some sites require that you send
Connection: Keep-alive; if the site/page requires it so you maintain a session on the server.
<FORM action="http://www.mysite.com/pagename.php" method="POST">
First Name: <INPUT type="text" name="FirstName"><br />
Middle Name: <INPUT type="text" name="MiddleName"><br />
Last Name: <INPUT type="text" name="LastName"><br />
<INPUT type="submit" value="OK"><br />
<INPUT type="hidden" name="LoggedIn" value="True">
</form>
- Method="GET"
http[/b]://www.mysite.com/pagename.php?FirstName=John&MiddleName=Q.&LastName=Public&LoggedIn=True - Method="POST"
POST http[/b]://www.mysite.com/pagename.php HTTP/1.1
Accept: text/html, image/gif, image/jpeg, */*
User-Agent: User-Agent: Mozilla/4.0 (compatible; MSIE 6.0b; Win32)
Pragma: no-cache
Content-type: application/x-www-form-urlencoded
Content-length: 58
FirstName=John&MiddleName=Q.&LastName=Public&LoggedIn=True
Your challenge will be to decode the <FORM> that's being submitted to that page. Then all you have to do is send back the correct headers (including cookie content, if any) in the correct format and then deal with the data that comes back to you from the server.
RFC 2616: Hypertext Transfer Protocol -- HTTP/1.1