Need Advice on PHP formail with captcha

Discussion in 'PHP' started by Lukas, Jan 27, 2007.

  1. #1
    Hi,

    anyone have a recommendation on a php formmail with captcha

    the captcha I am looking for is one with logic...such as:

    1.) what's the sum of 23 and 40 ?
    2.) or answering a simple question - the color of a banana , on sunny days, the sky is .? ( blue)

    the image captchas with gif images seem to have problems with eye strain or simply unreadable text or numbers.

    I need this for a hmtl application form & a contact form.

    why..? b/c of those pesky spammers

    last request - FREE is good or will pay small amount.

    thanks
     
    Lukas, Jan 27, 2007 IP
  2. PureLuckk

    PureLuckk Peon

    Messages:
    21
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    If you know PHP to an extent and know how to program your own form then adding this to your form will be easy. It's an PHP Captcha, however it does not have the logic questions you were seeking, sorry. (I can not post url's yet so replace the bold DOT with a period).

    URL: www DOT white-hat-web-design.co.uk/articles/php-captcha.php
     
    PureLuckk, Jan 27, 2007 IP
  3. clancey

    clancey Peon

    Messages:
    1,099
    Likes Received:
    63
    Best Answers:
    0
    Trophy Points:
    0
    #3
    You can use this as a template:

    
    <?php
    session_start();
    $scriptURL = "http://YOUR-DOMAIN/cap.php";
    if(!empty($_POST['submit']) )
    	{
    	if(!empty( $_POST['comment'] )) { $theComment = $_POST['comment']; }
    	if(!empty( $_POST['captcha'])) { $captcha = $_POST['captcha']; }
    
    	if ($captcha != $_SESSION['captcha_code'])
    		{
    		$captchaERR = "Security code entry did not match. Please retry<br />";
    		$formErrors = true;
    		}
    	if($formErrors) { ShowForm( $scriptURL, $captchaERR , $theComment); exit; }
    	else { echo "Thank you for your comments"; exit; }
    	
    	}
    
    else { ShowForm( $scriptURL ); }
    exit;
    
    ################################################
    # Build and show the form
    function ShowForm( $scriptURL, $captchaERR = "", $theComment = "" )
    {
    $captcha = GetCaptcha();
    echo '
    <form action="' . $scriptURL . '" method="post">
    <p>Feedback</p>
    <textarea rows="4" name="comment" cols="40">'.$theComment.'</textarea>
    <p>' . $captchaERR . $captcha . '<input type="text" name="captcha" value=""  size="50" /></p>
    <p align="center"><input type="submit" value="Send Feedback" name="submit" /></p>
    </form>';
    
    }
    
    function GetCaptcha()
    {
    $numA = rand(10, 50);
    $numB = rand(10, 50);
    $sum = $numA + $numB;
    $_SESSION['captcha_code'] = $numA + $numB;
    $question = "What is the sum of $numA and $numB?";
    return $question;
    }
    
    ?>
    
    PHP:
     
    clancey, Jan 27, 2007 IP
  4. brendandonhue

    brendandonhue Peon

    Messages:
    45
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    IMO a simple text CAPTCHA like adding numbers isn't really going to stop bots.
     
    brendandonhue, Jan 27, 2007 IP
  5. PureLuckk

    PureLuckk Peon

    Messages:
    21
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Why do you say that? Bots can not read images?
     
    PureLuckk, Jan 28, 2007 IP
  6. soyturk

    soyturk Active Member

    Messages:
    112
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    73
    Digital Goods:
    1
    #6
    $_SERVER['HTTP_REFERER'] == 'your form'
    accept
    ELSE
    deny

    ---- and -----

    Real IP Adress
    http://www.soyturk.com/code/real_ip_adress.phps

    ---- and -----

    he login to form page time
    md5(time());

    ---- and ------

    1. referer
    2. ip
    3. time

    writing to sql or txt or .....
    txt name is xxxxadasda (time, ip vs. vs. vs. )

    session txt name;

    after posted

    control
    txt is exists
    open txt
    referer = referer
    ip = ip
    time = time

    Accepted

    Else

    Deny

    ;)
     
    soyturk, Jan 28, 2007 IP
  7. Barti1987

    Barti1987 Well-Known Member

    Messages:
    2,703
    Likes Received:
    115
    Best Answers:
    0
    Trophy Points:
    185
    #7
    Barti1987, Jan 28, 2007 IP
  8. brendandonhue

    brendandonhue Peon

    Messages:
    45
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #8
    I was replying to the post above mine that gave a text captcha (not image.)
     
    brendandonhue, Jan 29, 2007 IP
  9. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #9
    Actually, they can. Most captcha images can be bypassed by good bots. But as azizny said, it stops most of them.
     
    nico_swd, Jan 29, 2007 IP
  10. ariyes

    ariyes Notable Member

    Messages:
    1,123
    Likes Received:
    45
    Best Answers:
    0
    Trophy Points:
    245
    #10
    ariyes, Jun 5, 2008 IP