cURL / Mailing Lists / curl-users / Single Mail


Re: SUMMARY: login POST with php/libcurl

From: Ralph Mitchell <>
Date: Thu, 08 May 2003 00:03:55 -0500

Just FYI, you probably should eyeball the form page anyway, especially if
something odd is happening.

I've had several instances where the form tag has had an "onSubmit" element
that executes some javascript. The javascript in question fiddled with the
form variables (i.e. changed some values), and in one memorable (=nasty!)
case, assembled a new form action url from the variables and then set

Believe me, I was not nice to know when I found *that* little piece of

Ralph Mitchell

Joe Glass wrote:

> Okay, I looked into it more and got my login to work. Below is the
> code. I was missing was the CURLOPT_COOKIEFILE line. Actually, the
> script doesn't work the first time because you have to set up the
> connection to create a cookie in /tmp/cookie, but if you click reload
> the cookie will be created and it will work.
> I'm still having problems getting working with that page.
> However I got it to work with the
> page. I got it to work
> with other pages, though.
> Thank you for your help Daniel,
> Joe Glass
> $id = "username";
> $pw = "password";
> $postfields = "UserLogin=$id&UserPassword=$pw";
> $ch = curl_init();
> curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); // Allow redirection
> curl_setopt($ch, CURLOPT_COOKIEJAR, "/tmp/cookie");
> curl_setopt($ch, CURLOPT_COOKIEFILE, "/tmp/cookie");
> curl_setopt($ch, CURLOPT_URL,
> "");
> curl_setopt($ch, CURLOPT_POST, 1);
> curl_setopt($ch, CURLOPT_POSTFIELDS, "$postfields");
> curl_exec($ch);
> curl_close($ch);
> unset($ch);

Enterprise Linux Forum Conference & Expo, June 4-6, 2003, Santa Clara
The only event dedicated to issues related to Linux enterprise solutions
Received on 2003-05-08