Jump to content

posting to a form with image verification with CURL


dsaba

Recommended Posts

this code keeps posting the wrong image verification code, to the form, because when it loads the form again to post the code that I retrieved the image verification code, is now changed

 

How can I do this successfully with curl? If you have any experience with using curl functions in php you CAN help me on this one.

 

<?php
if (!isset($_GET['code'])) {
$formurl = 'http://p2mcity.freehostia.com/mh-db.php?add=problem';

$curlit = curl_init();	
curl_setopt($curlit, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($curlit, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curlit, CURLOPT_URL, $formurl);
$result = curl_exec($curlit);
$oneArray = explode('<td height="14"><input name="captcha" type="text" size="6" maxlength="5" />', $result);
$twoArray = explode('</td>', $oneArray[1]);
$image = $twoArray[0];	  
echo $image; //this echoes back the image for image verification from the html form

echo '<form action="imagecurl.php" method="get" name="whatever">
Type in the code: <input name="code" type="text" size="6" maxlength="5" /><input type="submit" value="Submit"/></form>';

} else {
$posturl = 'http://p2mcity.freehostia.com/mh-db.php';
$curlit = curl_init();	
curl_setopt($curlit, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($curlit, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curlit, CURLOPT_URL, $posturl);
curl_setopt ($curlit, CURLOPT_POSTFIELDS, "title=whatever&description=whatever&mhversion=123&nickname=whatever&[email protected]&livecontact=whatever&service=whatever&captcha=".$_GET['code']."&add=suggestion&Submit33=Submit");	
$result = curl_exec($curlit);	
echo $result;

}
?>

 

 

here is the live script where I uploaded and tested it with:

http://p2mcity.freehostia.com/imagecurl.php

-thank you

 

I'm new to PHP and am unsure what CURL is, but just so you have something to look into if you would like to give your brain a break.

 

Here's what I believe may be an alternative:

http://gabrieljones.com/2007/03/29/creating-a-php-verification-image/

thanks for reading :)

 

but you've misread my question, my question is not about how to create an image for verification

 

but on how to use CURL to post to a form that requires a code to be typed for image verification

 

curl is a set of functions compiled into php that allows you to do remote http connections, including posting to forms

 

the problem with my current algorithim in doing this is that, first i load the page once to grab teh image, spit it back to my script and then I submit the code into a form, then i load the form AGAIN to post the information with the code i just typed, the problem is that the second time I load the form a NEW image verification has been generated, so i need to create some kind of algorithim to where i can retrieve the image, send the image back to my script, and post the new data to the form with the code, all in ONE page load

 

thats what I need help figuring out, the above code is the only alogorithim i know of, I need phpfreaks help in showing me the correct way to do what I want to do, because obviously my method is not working

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.