Page 1 of 1

php_curl help

Posted: Mon Nov 14, 2005 10:29 pm
by heya
feyd | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]


Hi, I am trying to create an auto log in script for http://www.12dailypro.com. code below:

Code: Select all

<?php
$var1 = 'email@yahoo.com';
$var2 = 'password';

$site = "http://www.12dailypro.com/";

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $site); 
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,"email=$username&passwd=$password&form='sent'");
curl_exec($ch);
curl_close($ch);
$direction = "http://www.12dailypro.com/members/?login=true&";

header("location: $direction");
?>
but i am not able to log in..

what is wrong with my code?
How can i make one that will enable me to log in the 12dailypro?

thanks.


feyd | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]

Posted: Mon Nov 14, 2005 10:45 pm
by feyd
$var1 vs $username
$var2 vs $password

:?: :?

Posted: Mon Nov 14, 2005 10:49 pm
by heya
sorry i just typed it incorrectly. it should be

Code: Select all

<?php
$username = 'email@yahoo.com';
$password = 'password';

$site = "http://www.12dailypro.com/";

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $site);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,"email=$username&passwd=$password&form='sent'");
curl_exec($ch);
curl_close($ch);
$direction = "http://www.12dailypro.com/members/?login=true&";

header("location: $direction");
?>
I'm getting:



I'm getting this page
Generated Tue, 15 Nov 2005 05:05:30 GMT by Prolexic.com (SICC2MIA1/1.0)

Posted: Mon Nov 14, 2005 10:58 pm
by feyd
curl_exec() will echo the results of the request if you don't specify that it should "return transfer"

Posted: Mon Nov 14, 2005 11:11 pm
by heya
what shall i do then?

i'm only getting this now.
Generated Tue, 15 Nov 2005 05:05:30 GMT by Prolexic.com (SICC2MIA1/1.0)

Posted: Mon Nov 14, 2005 11:34 pm
by feyd
I was hinting at the curl option for returning the transfer ;)

Posted: Tue Nov 15, 2005 3:10 am
by heya
you mean setting the option to let the curl return the header?

sorry i really dont get it...

Posted: Tue Nov 15, 2005 7:30 pm
by heya
anyone? help.

Posted: Tue Nov 15, 2005 7:42 pm
by trukfixer
heya wrote:anyone? help.
http://us2.php.net/manual/en/function.curl-exec.php

In Other words, "RTFM"

http://www.catb.org/~esr/faqs/smart-questions.html

In other words, Learn how to ask good questions

viewtopic.php?t=8815

In other words, Read the site's guidelines.