Jump to content

CURL help (pleeeaaseee) :D


StirCrazy

Recommended Posts

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  ;D

 

 

 

S.C>

 

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.