Page 1 of 1

Setting up captcha with a conditional

Posted: Wed Nov 11, 2009 8:05 pm
by Vinn1e
hey guys im new to codding and am in deep , lol want to insert a captcha in my script but alternate it appearing based upon a random number.

Please if any one can tell me where im going wrong. cheers

Code: Select all

 
 
 
<center>
<?
$random_number = rand(1,10);
if ( $random_number <= 7 )}
 {else} 
require_once('recaptchalib.php');
$publickey = "*****"; // you got this from the signup page
echo recaptcha_get_html($publickey);
{
?>
</center>

this is the bit that came wit recaptcha and loads the process , above that was my first attempt at a conditional.

Code: Select all

require_once('recaptchalib.php');
$publickey = "*****"; // you got this from the signup page
echo recaptcha_get_html($publickey);
{
any help getting this working would be huge.

Thanks in advance

Re: Setting up captcha with a conditional

Posted: Tue Nov 17, 2009 8:53 am
by akuji36
Hello

Take a look at this:

http://www.finalwebsites.com/snippets.php?id=39

thanks

Rod

:)

Re: Setting up captcha with a conditional

Posted: Tue Nov 17, 2009 10:27 am
by timWebUK
Was this what you were trying to achieve?

Code: Select all

 <?php
 
    $random_number = rand(1,10);
    if ( $random_number < 8 )
    {
        require_once('recaptchalib.php');
        $publickey = "*****"; // you got this from the signup page
        echo recaptcha_get_html($publickey);
    }
    else
    {
    //Additional Code Here
    }
    
?> 
Although this would work, when you sent the form to the PHP processing file, you would still have the reCAPTCHA private key there... so this wouldn't work.

Why do you want it to randomly appear?