cURL issue - Form filler example not working
Posted by: dfobare (---.twmi.res.rr.com)
Date: August 12, 2007 04:08PM

I'm trying to run a simple PHP form filler; here is the code:


$post = "username=myusername&password=mypassword";
$ch = curl_init("[www.thesite.com]winking smiley;
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$out = curl_exec($ch);

echo $out;

All I'm getting is the /privatelogin page back, as if the POSTFIELDS command ain't working. I cribbed the above example directly from Practical PHP Programming. cURL is enabled properly by editing php.ini under Apache2. For example, here is another trivial snippet which does work:

$ch = curl_init("[www.google.com]winking smiley;
$fp = fopen("example_homepage.txt", "w"winking smiley;

curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 0);

curl_exec($ch);
curl_close($ch);
fclose($fp);

So I'm thinking that my problem lies in the CURLOPT commands, and that CURL_POSTFIELDS is the culprit. I'm running 1.7.2 under XP Pro.

Should I report this to the cURL people?

Options: ReplyQuote
Re: cURL issue - Form filler example not working
Posted by: CyberSpatium (---.hsd1.or.comcast.net)
Date: August 12, 2007 10:38PM

try this (i have not tested this, so i cannot guarantee this will work 100%):

$post = "username=myusername&password=mypassword";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "[www.thesite.com]winking smiley;
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$out = curl_exec($ch);
curl_close($ch);




CyberSpatium
----------------------
WAMP English Forum Admin

Need help? Check out my WAMP User Manual/Guide here!


Cellular Phone Deals - The Best on the Net! - FREE PHONES! Take your pick from our featured cellular phone deals by Cingular, Verizon, T-Mobile, Sprint PCS, Nextel, and more! Most of our cellular phone offers include a FREE cellular phone with FREE shipping!


Web Development for Newbie's Blog - Check out my new blog. It is for web developers, and especially tailored for the web development newbie. If you are not fluent in “geek speak”, then this incredible resource is just you. And even if you are a web development pro, this is a great resource to check out some of the latest web development tips, news, tutorials, codes and more.


Clarify Loans
Mortgage and Home Loan Advice


LaxGo Web Directory
Powerful human edited web directory of quality, spam-free sites organized via a comprehensive category structure.

Options: ReplyQuote
Re: cURL issue - Form filler example not working
Posted by: dfobare (---.twmi.res.rr.com)
Date: August 12, 2007 11:23PM

Unfortunately that didn't help. Same response.

Options: ReplyQuote


Sorry, only registered users may post in this forum.