php_curl help

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
heya
Forum Newbie
Posts: 10
Joined: Thu Oct 06, 2005 2:53 am
Location: Manila, Philippines

php_curl help

Post 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]
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

$var1 vs $username
$var2 vs $password

:?: :?
heya
Forum Newbie
Posts: 10
Joined: Thu Oct 06, 2005 2:53 am
Location: Manila, Philippines

Post 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)
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

curl_exec() will echo the results of the request if you don't specify that it should "return transfer"
heya
Forum Newbie
Posts: 10
Joined: Thu Oct 06, 2005 2:53 am
Location: Manila, Philippines

Post 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)
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

I was hinting at the curl option for returning the transfer ;)
heya
Forum Newbie
Posts: 10
Joined: Thu Oct 06, 2005 2:53 am
Location: Manila, Philippines

Post by heya »

you mean setting the option to let the curl return the header?

sorry i really dont get it...
heya
Forum Newbie
Posts: 10
Joined: Thu Oct 06, 2005 2:53 am
Location: Manila, Philippines

Post by heya »

anyone? help.
User avatar
trukfixer
Forum Contributor
Posts: 174
Joined: Fri May 21, 2004 3:14 pm
Location: Miami, Florida, USA

Post 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.
Post Reply