function recaptcha($key) { global $captcha_img, $captcha_id, $challenge; //Curl $ch=curl_init(); curl_setopt($ch, CURLOPT_URL, 'http://api.recaptcha.net/challenge?k='.$key); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $response=curl_exec($ch); curl_close($ch); //Parse content $regexp='/challenge : '(.*?)',/is'; preg_match($regexp, $response, $challenge); //Image captcha $captcha_id=$challenge[1]; $captcha_img='<img src="http://www.google.com/recaptcha/api/image?c='.$captcha_id.'">'; }