Captcha

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • arnage
    replied
    I don't know for the archive but posted instructions are full of errors.

    Leave a comment:


  • razzbee
    replied
    INSTRUCTIONS

    I am sorry,I wrote the instruction with my mobile whiles in a bus...The captcha code is working perfectly

    Demo : De $ Makers
    The instruction is edited,errors removed,plz post back if U have other errors,again you can edit it to suit your
    preferance

    STEP 1

    Extract the content to your root folder ,that is public_html or htdocs


    STEP 2
    Put the code below inbetween the <head> </head> of your registration page

    CODE :

    session_start();
    ----------------------------------------

    STEP 3
    add the code below to your form..your form must be with the extension name.php

    CODE :

    <div class='form-captcha'>Captcha<br>
    <span align='left'><img src='captcha.php' alt='captcha' /></span>
    </div><br>
    <div>

    <input type='text' name='captcha' placeholder='enter captcha' /> </div>
    <div >
    -------------------------------------------------------------------------
    STEP 4
    Put the code below inbetween the <head> </head> of your registration page

    CODE :

    session_start();


    STEP 5

    add this to the page that will proccess the registration form

    CODE :

    //getting the captcha security codes
    $session_captcha=$_SESSION['captcha_code'];

    $user_captcha=$_POST['captcha'];

    //cleaning our captcha codes
    $user_captcha=htmlentities($user_captcha);

    if(!preg_match("/(^[a-zA-Z0-9]+)$/",$user_captcha)){


    die("Captcha code is invalid");


    }

    //comaparing if the captcha codes matches
    if(!strcmp($user_captcha,$session_captcha)=='0'){

    die("The security code you entered is invalid");

    }//end captcha check

    The instruction is edited,errors removed,plz post back if U have other errors,again you can edit it to suit your
    preferance

    I am sorry,I wrote the instruction with my mobile whiles in a bus...The captcha code is working perfectly

    Demo : De $ Makers
    Attached Files
    Last edited by razzbee; 18.10.11, 22:39. Reason: errors in instructions

    Leave a comment:


  • morse
    replied
    Originally posted by razzbee View Post
    Gumslone..Why are You confusing the guy if you dont want to teach him the how to do it best..I believe in teaching one how to fish so that he can fish and become better...anyway I still believe that code up there is a crap since bots can still read that thing cos before i create a bot I will have to check your html form input source code first,dont think the hidden attribute will save U ..Session I know is one of the best way to track captcha code both for mobile and pc,only that the session id is best in url for mobile that cookies(I never agreed with Gumslone that session is not the best)...
    I disagree, session is a very stupid thing to be done for mobile community sites. I ended up junking session system for pure cookie based authentication (this one sucks even more) but atleast it avoids all session expiry , session change problems.

    Leave a comment:


  • ASNirman
    replied
    Originally posted by metulj View Post
    subzero's entire post in TXT => ziped
    Thanks...

    Leave a comment:


  • metulj
    replied
    Originally posted by ASNirman View Post
    @subzero can u give captcha.php on a zip file?
    subzero's entire post in TXT => ziped
    Attached Files

    Leave a comment:


  • ASNirman
    replied
    @subzero can u give captcha.php on a zip file?

    Leave a comment:


  • subzero
    replied
    1) Make a PHP script (separate file captcha.php) which will generate the image:
    Code:
    <?php 
    session_start(); 
    header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");  
    header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");  
    header("Cache-Control: no-store, no-cache, must-revalidate");  
    header("Cache-Control: post-check=0, pre-check=0", false); 
    header("Pragma: no-cache");  
    
    function _generateRandom($length=6) 
    { 
        $_rand_src = array( 
            array(48,57) //digits 
            , array(97,122) //lowercase chars 
    //        , array(65,90) //uppercase chars 
        ); 
        srand ((double) microtime() * 1000000); 
        $random_string = ""; 
        for($i=0;$i<$length;$i++){ 
            $i1=rand(0,sizeof($_rand_src)-1); 
            $random_string .= chr(rand($_rand_src[$i1][0],$_rand_src[$i1][1])); 
        } 
        return $random_string; 
    } 
    
    $im = @imagecreatefromjpeg("captcha.jpg");  
    $rand = _generateRandom(3); 
    $_SESSION['captcha'] = $rand; 
    ImageString($im, 5, 2, 2, $rand[0]." ".$rand[1]." ".$rand[2]." ", ImageColorAllocate ($im, 0, 0, 0)); 
    $rand = _generateRandom(3); 
    ImageString($im, 5, 2, 2, " ".$rand[0]." ".$rand[1]." ".$rand[2], ImageColorAllocate ($im, 255, 0, 0)); 
    Header ('Content-type: image/jpeg'); 
    imagejpeg($im,NULL,100); 
    ImageDestroy($im); 
    ?>
    2) Add the following line at the top of the page where you need to implement CAPTCHA:
    Code:
    <?php session_start() ?>
    3) Add the following line to check whether the CAPTCHA string entered by the visitor is valid, before the line where you will proceed with a submitted message:
    Code:
    <?php 
    if($_SESSION["captcha"]==$_POST["captcha"])
    {
        //CAPTHCA is valid; proceed the message: save to database, send by e-mail ...
    }
    ?>
    4) Finaly add the CAPTCHA to the form:
    Code:
    <?php session_start() ?>
    <form method="post" action="">
    <table bgcolor="#CCCCCC">
    <tr><th>Contact us (Post new message):</th></tr>
    <tr><td><textarea cols="30" rows="5" name="message"></textarea></td></tr>
    <tr><td align="center">CAPTCHA:<br>
        (antispam code, 3 black symbols)<br>
        <table><tr><td><img src="captcha.php" alt="captcha image"></td>
        <td><input type="text" name="captcha" size="3" maxlength="3"></td></tr></table>
    </td></tr>
    <tr><th align="center"><input type="submit" value="Submit"></th></tr>    
    </table>
    </form>
    <?php
    if(isset($_POST["captcha"]))
    if($_SESSION["captcha"]==$_POST["captcha"])
    {
        //CAPTHCA is valid; proceed the message: save to database, send by e-mail ...
        echo 'CAPTCHA is valid; proceed the message';
    }
    else
    {
        echo 'CAPTCHA is not valid; ignore submission';
    }
    ?>

    Leave a comment:


  • GumSlone
    replied
    Originally posted by razzbee View Post
    Gumslone..Why are You confusing the guy if you dont want to teach him the how to do it best..I believe in teaching one how to fish so that he can fish and become better...anyway I still believe that code up there is a crap since bots can still read that thing cos before i create a bot I will have to check your html form input source code first,dont think the hidden attribute will save U ..Session I know is one of the best way to track captcha code both for mobile and pc,only that the session id is best in url for mobile that cookies(I never agreed with Gumslone that session is not the best)...
    first of all, there are several captcha scripts here in forums which he could find using the site search,
    second, he wanted a text captcha so i gave him an example how he could do it and told that it was not very clever to use that type of captcha,
    and last third thing, if you were an experienced wapmaster you would know that sessions/cookies are not the best way for captcha on mobile phone.

    Leave a comment:


  • razzbee
    replied
    Originally posted by hider View Post
    ok here it is

    add it ur register form page
    Code:
    $hider=rand(1000,100000);
    <small><b>Enter This Code Below:*</b></small><br/>
    <b>$hider</b><br/>
    <input type=\"hidden\" name=\"scode\" value=\"$hider\"/>
    and the post field
    Code:
    <postfield name=\"code\" value=\"$(code)\"/>
    and post
    Code:
    $code=htmlspecialchars(stripslashes(trim($code)));
    $scode=htmlspecialchars(stripslashes(trim($scode)));
    $pcode=htmlspecialchars(stripslashes(trim($pcode)));
    and the error msg
    Code:
    if(($code) != ($scode)) $error='Incorrect security code!<br/>Please Enter Correct Code Shown In Last Page<br/>';
    njoy bro
    Gumslone..Why are You confusing the guy if you dont want to teach him the how to do it best..I believe in teaching one how to fish so that he can fish and become better...anyway I still believe that code up there is a crap since bots can still read that thing cos before i create a bot I will have to check your html form input source code first,dont think the hidden attribute will save U ..Session I know is one of the best way to track captcha code both for mobile and pc,only that the session id is best in url for mobile that cookies(I never agreed with Gumslone that session is not the best)...

    Leave a comment:


  • jaidon20k
    replied
    Ok i need that math captcha with on background image

    Leave a comment:


  • bivaswap
    replied
    @ ionutvmi

    yes you r right, thats i am trying to say!

    Leave a comment:


  • hider
    replied
    ok here it is

    add it ur register form page
    Code:
    $hider=rand(1000,100000);
    <small><b>Enter This Code Below:*</b></small><br/>
    <b>$hider</b><br/>
    <input type=\"hidden\" name=\"scode\" value=\"$hider\"/>
    and the post field
    Code:
    <postfield name=\"code\" value=\"$(code)\"/>
    and post
    Code:
    $code=htmlspecialchars(stripslashes(trim($code)));
    $scode=htmlspecialchars(stripslashes(trim($scode)));
    $pcode=htmlspecialchars(stripslashes(trim($pcode)));
    and the error msg
    Code:
    if(($code) != ($scode)) $error='Incorrect security code!<br/>Please Enter Correct Code Shown In Last Page<br/>';
    njoy bro
    Last edited by hider; 16.10.11, 18:17.

    Leave a comment:


  • ionutvmi
    replied
    he means if i click submit nothing is stoping me to click refresh and that code is useless...
    If you want to do text you can do something like: whats 3+4 ?
    Just store in an array the question =>answer and random select one to be displayed and put the answer in session just like image captcha

    Leave a comment:


  • GumSlone
    replied
    Originally posted by jaidon20k View Post
    May he mean no $_SESSION[]
    what for?
    there are many different ways to create captcha, session is not the best solution for captche on a mobile site.

    Leave a comment:


  • jaidon20k
    replied
    May he mean no $_SESSION[]

    Leave a comment:

Working...
X