For the past few days, I've been wrecking my brain trying to get a php script to submit a form in PHP with CURL.
This is the source code of the site:
<form name="webform" action="mailto.php" method="post" onsubmit="return validateform(webform);">
<input type="hidden" name="submit" value="1">
<input type="hidden" name="name1" value="244959">
<input type="hidden" name="name2" value="<? echo $dogname; ?>">
<tr>
<td><font face="verdana" size="-1">Your Name: </td>
<td><input type="text" name="name"></td>
</tr>
<tr>
<td><font face="verdana" size="-1">Your Email Address: </td>
<td><input type="text" name="email"></td>
</tr>
<tr>
<td><font face="verdana" size="-1">Confirm Your Email Address: </td>
<td><input type="text" name="confirm_email"></td>
</tr>
<tr>
<td valign="top"><font face="verdana" size="-1">Your Message:</td>
<td><textarea name="comments" rows="8" cols="35"></textarea></td>
</tr>
<tr>
<td> </td>
<td><img src="captcha.php"></td>
</tr>
<tr>
<td><input type="text" name="vercode" /></td>
</tr>
<tr>
<td><input type="submit" class=button name="Send" value="submit">
<br>
<br></td>
</tr>
</form>
</table>
This is the code for the submission script:
function postform($id){
grab_image('path to/captcha.php', 'captcha.jpg');
$image = 'captcha.jpg';
$client = new DeathByCaptcha_SocketClient("user", "password");
if ($captcha = $client->decode($image, 10)) {
echo $captcha['text'] . "\n";
$url = "path to page.php";
$data = array();
$data['submit']='1';
$data['name1']=$id;
$data['name2']="name2";
$data['name']='MyName';
$data['email']='[email protected]';
$data['confirm_email']='[email protected]';
$data['comments']='Success Posting This Form';
$data['vercode']=$captcha['text'];
$post_str = '';
foreach($data as $key=>$value){
$post_str .= $key.'='.urlencode($value).'&';
}
$post_str = substr($post_str, 0, -1);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url); // set url to post to
curl_setopt($ch, CURLOPT_POST, TRUE); // set POST method
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_str);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,TRUE); // return into a variable
$result = curl_exec($ch); // run the whole process
curl_close($ch);
echo $result;
}
}
postform("page number");
Once I execute the code however, I get back as a result: "Security code missing. Please go back and try again."
Been tinkering around with this for a few days now and I'm a little stumped on how to proceed. Any help would be immensely appreciated!
mailto.phpthe same ashttp://www.breeders.net/mailto.php?action='mail_curl.php'then onmail_curl.php, we can have the curl code to submit the data to...../mailto.php. Since in your html page you have the breederid, we dont need to pass it to...../mailto.php?id=244959