ziikutv Posted August 28, 2009 Share Posted August 28, 2009 I have a form script which displays $output. And I have made different vars like $output so they display for example if one types invalid email ID, it will use "$output = $invalidID". and $invalidID equals to a text saying "Invalid email provided". I've added reCAPTCHA and it works fine as well. But when one types in invalid captcha, the form disappears (Captcha is between the form tags) and it says the text when wrong captcha is typed. This is the captcha's code which does verification. require_once('captcha/recaptchalib.php'); $privatekey = "xxxxx"; $resp = recaptcha_check_answer ($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]); if (!$resp->is_valid) { die ("Invalid Captcha entered"); } So what I want to do is setup a variable called $invalidcap and set it to a text saying invalid captcha entered. And display that text in $output so that it doesn't make the form and captcha disappears and show the text "invalid captcha entered" instead shows it where I set the $output to. How do I do that? So in english this is what I want to do, When die, make $output = $invalidcap in the display field which has the following HTML CODE <p class="response" style="height: 1px"><?=$output?></p> Quote Link to comment https://forums.phpfreaks.com/topic/172226-combining-two-php-scripts/ Share on other sites More sharing options...
oni-kun Posted August 28, 2009 Share Posted August 28, 2009 Well what you're trying to do is this? die() exits the page, thus preventing the form from finishing etc. I'd recommend just doing this.. //Form code here... {<form>} if (!$resp->is_valid) { echo '<p class="response" style="height: 1px">'.$output.'</p>'; } else { echo 'Correct.'; //do something if captcha was correct! } Take out the previous 'if' from the captcha code, and place this new one wherever you wish for the error to be displayed, if that's what you wanted. Quote Link to comment https://forums.phpfreaks.com/topic/172226-combining-two-php-scripts/#findComment-908047 Share on other sites More sharing options...
ziikutv Posted August 28, 2009 Author Share Posted August 28, 2009 I did that and then it will PASS the Captcha without me entering anything at all :S Captcha is not working for me atm. Is there any way we can talk privately ? I will show you my code and then you would be able to make it work for me probably. Quote Link to comment https://forums.phpfreaks.com/topic/172226-combining-two-php-scripts/#findComment-908069 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.