cURL / Mailing Lists / curl-and-php / Single Mail

curl-and-php

Re: curl-and-php Digest, Vol 24, Issue 8

From: Dave Fobare <editor_at_the-sports-page.com>
Date: Mon, 13 Aug 2007 21:51:25 -0400

On iehttpheaders: I haven't been able to get the addon to work on
multiple machines. If there is a Firefox equivalent, I'll give it a try.

The suggested snippet below did not help. I did implement a number of
suggestions on the CURL page at php.net.

I inserted the following line to enable redirects:

curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);

And I also added the following snippet to enable cookies on Windows:

$cookies = "cookie.txt";

if ($cookies != '')
    {
    if (substr(PHP_OS, 0, 3) == 'WIN')
        {$cookies = str_replace('\\','/', getcwd().'/'.$cookies);}
    curl_setopt($ch, CURLOPT_COOKIEJAR, $cookies);
    curl_setopt($ch, CURLOPT_COOKIEFILE, $cookies);
   }

Same results on both of my test pages. I'll elaborate on the simpler of
the two login pages:

Login page URL: http://www.mysite.com/index.cfm

The input form has just the following fields:

<form action="login2.cfm" method="post">
<input type="Text" name="UserID" maxlength="40" size="30">
<input type="Password" name="Password" maxlength="30" size="30">
<input type="submit" value=" Log In " class="button">

And there are no other FORMs on the page. The login2.cfm script leads to
the actual destination page, http://www.mysite.com/home.cfm.

What should I try next?

Thanks,

Dave Fobare
> $post['UserID'] = "myuserid"
> $post['Password'] = "mypassword";
>
> $ch = curl_init();
> curl_setopt($ch, CURLOPT_URL, "http://www.mysite.com/privatelogin" );
> curl_setopt($ch, CURLOPT_POST, 1 );
> curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
> curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
> $postResult = curl_exec($ch);
>
> if (curl_errno($ch)) {
> print curl_error($ch);
> }
> curl_close($ch);
> print "$postResult";
>
> php.net is a great resource for code snippets:
>
> http://us2.php.net/manual/en/ref.curl.php
>
> Mark
>

_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
Received on 2007-08-14