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

curl-and-php

Form Post in php with cURL

From: PDQ <as400_at_pdq.net>
Date: Fri, 16 Apr 2004 19:36:57 -0500

I am trying to implement the form below using cURL & php, expecting a list of jobs returned.
The one thing I dont understand is the form 'action' it appears to be a directory instead of
a script or cgi because there is no extension at the end of 'JobSearch'. Regardless the form below works but the cURL right below it doesnt, the cURL returns HTTP/1.1 302 Moved Temporarily...

It just seems it cant get any simpler than this ... there is not much more I can do, what am I missing?

Do I need a name & value for the 'submit' button, which doenst have one?

thanks
joe mcdonald

<!- ---------------------------------------------------------------------------------------- -->
<form action="http://seeker.dice.com/jobsearch/servlet/JobSearch" method="post">
  <input type="hidden" name="op" value="1013">
  <input type="hidden" name="rel_code" value="1102">
  <input type="text" name="FREE_TEXT" style="width:160px">
  <input align="absmiddle" src="new_images/button_search.gif" height="19" width="61" border="0" alt="Search" type="image">
</form>
<!- ---------------------------------------------------------------------------------------- -->

<?php
$url = "http://seeker.dice.com/jobsearch/servlet/JobSearch";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url); // set url to post to
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); // allow redirects
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); // return into a variable
curl_setopt($ch, CURLOPT_TIMEOUT, 0); // times out after Ns
curl_setopt($ch, CURLOPT_POST, 1); // set POST method
curl_setopt($ch, CURLOPT_POSTFIELDS, "FREE_TEXT=php&op=1013&rel_code=1102"); // add POST fields

curl_setopt($ch, CURLOPT_FAILONERROR, 0);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_COOKIEFILE, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);

$result = curl_exec($ch); // run the whole process
curl_close($ch);
echo $result;
?>
Received on 2004-04-17