Let's say i want the contents of www.example.com/page.php, but it will not display the correct page until i login at www.example.com/ first. Basically there is one input box and a button, and i want to simulate typing something into that, then i want to grab the source code of that page. Could someone give me an example of this in php?
probably not because the input box and button are most likely then handled by either the original file or a form handler before then redirecting onto page.php. The only way to do this would be to code something that will emulate a browser to trigger the form handler and allow itself to be redirected.
You need to post login data to the first page, save the cookies, then send them with your subsequent request. Curl is the best tool for this. There should be ample examples on the net.
Yes, CURLOPT_POSTFIELDS will give you what you're looking for. Cookie support might not be necessary as some sites will use sessions to track your activity.
If you expect it to be automatic without user involved, libcurl would be the best solution. But if you are just annoyed with your favourive webpage that makes you do that, you can use new firefox addons. You can record macros for some behaviours for specific websites.