Jump to content

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=whatever@whatever.com&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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.