StirCrazy Posted February 9, 2007 Share Posted February 9, 2007 Hi folks, I'm trying login into a website and store a webpage (that contains a sales report) in a variable. So far I can login using:- curl_setopt($ch, CURLOPT_URL, $login_url); curl_setopt ($ch, CURLOPT_POST, 1); curl_setopt ($ch, CURLOPT_POSTFIELDS, $login_post); curl_setopt ($ch, CURLOPT_COOKIEJAR, 'cookies!.txt'); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); But the reports page isn't the first page of the website. So I need to login, goto the reports page, submit the form details and capture the results in a variable. What I need is to login in using:- $login_url = Login Page $login_post = Contains login $_POST details This is the page with the reports FORM:- $reports_page = The URL with the form to select report post these details:- $reports_post = Contains $_POST details to this page $contents_url = The URL that the $_POST details are sent to ...and store the results in $page_contents Does that make any sense? I hope someone can help S.C> Quote Link to comment Share on other sites More sharing options...
Orio Posted February 9, 2007 Share Posted February 9, 2007 You need to: 1) Go to the login page (that one the processes the login) and send the post data for a login. 2) Go to the page that processes the form and send the post/get data for it. 3) Do what ever you want with the result from part 2. Now, most likely that either the site uses cookies for the login, or sessions and then sends you the session id (in most of the cases) in a cookie. So you need to use the CURLOPT_COOKIEFILE option in all of the curl requests. Add this to both of the requests: curl_setopt ($ch, CURLOPT_COOKIEFILE, "tmp/some-random-name"); Orio. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.