I want to make a multi registration form that posts on multiple sites the user doesn't need to type the same data over and over but he will post it on this form.The problem is that some sites may have captcha so I need a way to retrieve the captcha image on my form using cookies,sessions, curl I don't know which method can help me.
The problem has became complex because I need to store the session id and cookies because if i submit the form the other sites should know that is the same user that got requested the captcha. The php script that I used to get the catpcha is:
$ch = curl_init($url);//Site url
curl_setopt($ch, CURLOPT_COOKIEJAR, $file); //Save the cookie to a temporary file on the server
curl_setopt($ch, CURLOPT_COOKIEFILE, $file);
curl_setopt($ch, CURLOPT_HEADER ,1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER ,1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION ,1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
$content = curl_exec($ch);
preg_match("'<div class=\"captchaimage\">(.*?)<a class=\"captcha-refresh-link hide\"'si", $content, $matches ); // getting the captcha image
echo $matches[1]; //Displaying the image
The first time when I use this code it shows a broken image:
When I refresh the page or I open in another tab the site that i request the captcha it shows the wanted captcha:
So I need some help because I haven't worked much with curl's and cookies and but I know the problem has a solution like this site https://www.betall.ie/register.html. I would appreciate some help :).
The php code is here: http://codepad.viper-7.com/FMKrGR