Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 3 123 LastLast
Results 1 to 15 of 37
  1. #1
    New to the CF scene
    Join Date
    Feb 2007
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Image Validation for registering a new user

    Hi,

    Iam new to PHP,Icreated one register page with some fields,.........


    Now I want make image verification for security..

    Please help me how to code for image validaton......

  • #2
    Regular Coder meth's Avatar
    Join Date
    Jan 2003
    Posts
    262
    Thanks
    0
    Thanked 9 Times in 9 Posts
    google > php captcha
    I do Web Design, Brisbane based.
    More time spent in PHP/MySQL Web Development.
    And Search Engine Optimisation takes up the rest of it.

  • #3
    New to the CF scene
    Join Date
    Feb 2007
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    hi,i have gone through the link send by you,tell me where can i get relevant information for image validation in the link.............

  • #4
    Regular Coder
    Join Date
    Jan 2007
    Posts
    213
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Well here is my captcha script that i use, i have attached all the files needed in a zip format, of course mine looks this way because of this damn smartbot that is causing so many forums grief but you can change it to your hearts content.

    PHP Code:
    <?php
        session_start
    ();

        
    $alphanum  "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
        
        
    // generate the verication code 
        
    $rand substr(str_shuffle($alphanum), 05);
        
    $rand substr(md5($rand), 05);
        
    // choose one of four background images
        
    $bgNum rand(13);
        
    $font $_SERVER['DOCUMENT_ROOT'] . "/ConvectionRegular.ttf";
        
        
    // create an image object using the chosen background
        
    $image imagecreatefromjpeg($_SERVER['DOCUMENT_ROOT'] . "/images/verification_background".$bgNum.".jpg");

        
    $textColor imagecolorallocate ($image828282); 
        
        
    // write the code on the background image
        
    $rand substr(str_shuffle($alphanum), 05);
        
    $rand1 strtoupper(substr(md5($rand), 01));
        
    $rand substr(str_shuffle($alphanum), 05);
        
    $rand2 strtoupper(substr(md5($rand), 01));
        
    $rand substr(str_shuffle($alphanum), 05);
        
    $rand3 strtoupper(substr(md5($rand), 01));
        
    $rand substr(str_shuffle($alphanum), 05);
        
    $rand4 strtoupper(substr(md5($rand), 01));
        
    $rand substr(str_shuffle($alphanum), 05);
        
    $rand5 strtoupper(substr(md5($rand), 01));
        
        
    $thecode $rand1.$rand2.$rand3.$rand4.$rand5;
        
        
    //echo $font;
        
    imagettftext($image18rand(-1212), 726$textColor$font$rand1);
        
    imagettftext($image18rand(-1212), 2931$textColor$font$rand2);
        
    imagettftext($image18rand(-1212), 4121$textColor$font$rand3);
        
    imagettftext($image18rand(-1212), 6624$textColor$font$rand4);
        
    imagettftext($image18rand(-1212), 8633$textColor$font$rand5);
            
        
        
    // create the hash for the verification code and put it in the session
        
    $_SESSION['paramil_verification'] = $thecode;
            
        
    // send several headers to make sure the image is not cached
        
    header("Expires: Mon, 26 Jul 1992 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");     

        
    // send the content type header so the image is displayed properly
        
    header('Content-type: image/jpeg');
        
        
    // send the image to the browser
        
    imagejpeg($image);
        
        
    // destroy the image to free up the memory
        
    imagedestroy($image);
    ?>
    that will help you along
    Attached Files Attached Files
    Matthew Bagley
    Paramiliar Design Studios
    Website Design | Website Development | Search Engine Optimisation (SEO)

  • #5
    Regular Coder westmatrix99's Avatar
    Join Date
    Dec 2006
    Location
    South Africa
    Posts
    307
    Thanks
    12
    Thanked 0 Times in 0 Posts
    I get this error:

    Fatal error: Call to undefined function imagecreatefromjpeg() in c:\Inetpub\wwwroot\usermail\captcha.php on line 14
    Thanks for you support!

  • #6
    Regular Coder
    Join Date
    Jan 2007
    Posts
    213
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Looks like GD isn't installed on the system
    Matthew Bagley
    Paramiliar Design Studios
    Website Design | Website Development | Search Engine Optimisation (SEO)

  • #7
    Regular Coder westmatrix99's Avatar
    Join Date
    Dec 2006
    Location
    South Africa
    Posts
    307
    Thanks
    12
    Thanked 0 Times in 0 Posts
    Ok so how to install?
    Thanks for you support!

  • #8
    New Coder
    Join Date
    Mar 2006
    Posts
    51
    Thanks
    1
    Thanked 0 Times in 0 Posts
    To install GD, open your php.ini, find line ;extension=php_gd.dll or ;extension=php_gd2.dll. remove the ";". done!

    neomaximus2k, could you please show the test script? I've try to make one but I cannot compare the results.

    Thank you...

  • #9
    Regular Coder westmatrix99's Avatar
    Join Date
    Dec 2006
    Location
    South Africa
    Posts
    307
    Thanks
    12
    Thanked 0 Times in 0 Posts
    Hi redfroc
    I have got it to work but would like to now just refresh the image without refreshing the whole page.
    Thanks for you support!

  • #10
    New to the CF scene
    Join Date
    Mar 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Post

    Thank you.
    I try modify it to more simple.

    PHP Code:
    <?php
    session_start
    ();
    $sAlp "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
    $iInd 5;
    for(
    $i 0$i $iInd$i ++)
    {
        
    $iRnd rand(0strlen($sAlp) - 1);
        
    $aStr[$i] = substr($sAlp$iRnd1);
    }
    $sStrjoin(""$aStr);
    $im imagecreate(5020) or die("Cannot Initialize new GD image stream");
    $background_color imagecolorallocate($im200255255);
    $text_color imagecolorallocate($im2331491);
    imagestring($im1832$sStr$text_color);
    $_SESSION['regcode'] = $sStr;

    header("Expires: Mon, 26 Jul 1992 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");
    header('Content-type: image/gif');

    imagegif($im);
    imagedestroy($im);
    ?>

  • #11
    Regular Coder westmatrix99's Avatar
    Join Date
    Dec 2006
    Location
    South Africa
    Posts
    307
    Thanks
    12
    Thanked 0 Times in 0 Posts
    This is one is cool:
    But how do I just refresh the image without the whole page?

    PHP Code:
    <form name="form1" method="post" action="">
      <
    table width="500" border="0" cellspacing="2" cellpadding="2">
        <
    tr>
          <
    td width="16%" align="right" nowrap><div align="left"><font color="#000000" size="2" face="Verdana, Arial, Helvetica, sans-serif">User Name:</font></div></td>
          <
    td colspan="2"><div align="left">
            <
    font size="2" face="Verdana, Arial, Helvetica, sans-serif">
            <
    input name="username" type="text" id="username" onFocus="MM_displayStatusMsg('Please enter your User Name');return document.MM_returnValue" maxlength="50">
          </
    font></div></td>
        </
    tr>
        <
    tr>
          <
    td width="16%" align="right" nowrap><div align="left"><font color="#000000" size="2" face="Verdana, Arial, Helvetica, sans-serif">Password:</font></div></td>
          <
    td colspan="2"><div align="left">
            <
    font size="2" face="Verdana, Arial, Helvetica, sans-serif">
            <
    input name="password" type="password" id="password" onFocus="MM_displayStatusMsg('Please enter your Password');return document.MM_returnValue" maxlength="50">
          </
    font></div></td>
        </
    tr>
        <
    tr>
          <
    td><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Code:</font></td>
          <
    td width="19%"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><img src="img.php" alt="">  </font></td>
          <
    td width="65%"><a href="#"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">refresh</font></a></td>
        </
    tr>
        <
    tr>
          <
    td><font size="2" face="Verdana, Arial, Helvetica, sans-serif">&nbsp;</font></td>
          <
    td colspan="2"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">&nbsp;</font></td>
        </
    tr>
        <
    tr>
          <
    td width="16%"><div align="left"><font face="Verdana, Arial, Helvetica, sans-serif"><font size="2"></font></font></div></td>
          <
    td colspan="2"><div align="left">
            <
    font size="2" face="Verdana, Arial, Helvetica, sans-serif">
            <
    input type="submit" name="Submit" value="Log In">
          </
    font></div></td>
        </
    tr>
      </
    table>
    </
    form
    Thanks for you support!

  • #12
    New Coder
    Join Date
    Mar 2006
    Posts
    51
    Thanks
    1
    Thanked 0 Times in 0 Posts
    hi westmatrix99
    where is the action when form is submitted? and how to compare between image code and user input?

    mm.. I think we should use script like AJAX to make new image code without refreshing page (I think, I cannot make sure). Or put image creation lines in a function, so we can just load the function.

  • #13
    Regular Coder westmatrix99's Avatar
    Join Date
    Dec 2006
    Location
    South Africa
    Posts
    307
    Thanks
    12
    Thanked 0 Times in 0 Posts
    The form will be submitted to anything like mail or database but do not know how to make the captcha and form work.

    Cheers
    West
    Thanks for you support!

  • #14
    New Coder
    Join Date
    Mar 2006
    Posts
    51
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Yes, westmatrix, I can't either.
    May somebody could help us...?

    Thank you very much...

  • #15
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,642
    Thanks
    2
    Thanked 405 Times in 397 Posts
    You can refresh it by setting the ID of the image tag and changing the URL like this:
    Code:
    <img src="captcha.php" id="image" /> <a href="#" onclick="javascript: document.getElementById('image').src = 'captcha.php?' + Math.random();">Refresh Image</a>
    Just make sure you aren't using the QUERY_STRING for anything in the file.


  •  
    Page 1 of 3 123 LastLast

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •