...

View Full Version : cURL Not Submitting Properly?



H3X
08-25-2009, 09:20 AM
I am using this code:

<?php
$post = array();
$post["Sentence"] = "the dog jumped over the lazy sheep";
$post["Constituents"] = "checked";
$post["NullLinks"] = "checked";
$post["AllLinkages"] = "checked";
$post["LinkDisplay"] = "on";
$post["ShortLength"] = "6";
$post["PageFile"] = "/docs/submit-sentence-4.html";
$post["InputFile"] = "/scripts/input-to-parser";
$post["Maintainer"] = "sleator@cs.cmu.edu";
$post["submit"] = "Submit one sentence";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"http://www.link.cs.cmu.edu/cgi-bin/link/construct-page-4.cgi#submit");
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.8.1.16) Firefox/2.0.0");
curl_setopt($ch, CURLOPT_REFERER, "http://link.cs.cmu.edu/link/submit-sentence-4.html");
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
$results = curl_exec($ch);
curl_close($ch);
echo $results;
?>


And trying to fetch the page that would contain the results. I instead, however, get a page that takes about 20 seconds to load that contains an error message. I have no idea what I'm doing wrong, and I have tried nearly everything. The page with the original form on it is: http://www.link.cs.cmu.edu/link/submit-sentence-4.html. When I just copy and paste the form their page to my page, then submit it manually, it works fine.
Thanks.

tailender1
08-25-2009, 07:43 PM
i think you should use urlencode to endoce them and use urldecode to decode and use them in your destination php script. This ensures sending of variable values accurately over pages...

H3X
08-25-2009, 10:30 PM
Just tried that, it doesn't help. Thanks though.

H3X
08-25-2009, 11:30 PM
This fixed it:

$post = http_build_query($post);



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum