+ Reply to Thread
Results 1 to 5 of 5

Thread: Image Verification

  1. #1
    Brandon Guest

    Image Verification

    Image Verification

    I'm sure all of you have gone to an email and when your logging in you get a message saying to verify the words in the box.

    This is for security so people can not make "bots" automatily sign-up for a service or send massive amounts of emails.

    You need PHP and the GD Library. (X10 has this installed)

    Create a php file and name it verification.php inside post this code.

    <FONT style="BACKGROUND-COLOR: #ffffff">
    PHP Code:
    <?php
    session_start
    ();
    $random trim($random);
    if (
    $new_string == $random){
    ON THIS LINE YOU MAY PLACE ANYTHING YOU WANT TO HAPPEN AFTER VERIFICATION 
    }
    else{
    echo 
    "Please go back and type the code exactly as shown.";
    }
    ?>
    Then create another file this time named form.php inside post this code.

    <FONT style="BACKGROUND-COLOR: #ffffff">
    PHP Code:
    <?php
    Header
    ("Content-Type: image/png");
    session_start();
    $new_string;
    session_register('new_string');
    echo 
    "<html><head><title>Verification Check</title></head>";
    echo 
    "<body>";
    $im ImageCreate(20040); 
    $white ImageColorAllocate($im255255255);
    $black ImageColorAllocate($im000);
    srand((double)microtime()*1000000); 
    $string md5(rand(0,9999)); 
    $new_string substr($string175);
    ImageFill($im00$black);
    ImageString($im49619$new_string$white);
    ImagePNG($im"verify.png");
    ImageDestroy($im);
    echo 
    "<img src=\"verify.png\">";
    echo 
    "<br><br>";
    echo 
    "Type the code you see in the image in the box below. (case sensitive)";
    echo 
    " <form action=\"formhandler.php\" method=post>";
    echo 
    "<input name=\"random\" type=\"text\" value=\"\">";
    echo 
    "<input type=\"submit\">";
    echo 
    "</form>";
    echo 
    "</body>";
    echo 
    "</html>";
    ?>

  2. #2
    Bryon is offline Administrator Bryon has disabled reputation
    Join Date
    Apr 2005
    Location
    Northfield, NH
    Posts
    7,608

    Re: Image Verification

    One suggestion, it really won't matter until PHP 6 is released (I believe it will be taken out then.. Maybe someone else could clarify this for me?)

    Your using session_register() to create and register session variables. That method is depreciated, so I would just recommend you (And others.. ) to use the $_SESSION super globe array and just edit/alert/delete variables from there like:
    PHP Code:
    $_SESSION['var_name'] = value
    Instead of:
    PHP Code:
    session_register('var_name');
    $var_name value
    Eh, just a suggestion.

    By the way, good tutorial. I'm sure many people will find a good use for this. :-)

  3. #3
    Brandon Guest

    Re: Image Verification

    Thanks NedreN your the PHP man!

  4. #4
    Jordan K is offline [B]tags dont work:([/B] Jordan K is an unknown quantity at this point
    Join Date
    May 2005
    Location
    Hamilton, Ontario, Canada
    Posts
    764

    Re: Image Verification

    Quote Originally Posted by NedreN
    One suggestion, it really won't matter until PHP 6 is released (I believe it will be taken out then.. Maybe someone else could clarify this for me?)

    Your using session_register() to create and register session variables. That method is depreciated, so I would just recommend you (And others.. ) to use the $_SESSION super globe array and just edit/alert/delete variables from there like:
    PHP Code:
    $_SESSION['var_name'] = value
    Instead of:
    PHP Code:
    session_register('var_name');
    $var_name value
    Eh, just a suggestion.

    By the way, good tutorial. I'm sure many people will find a good use for this. :-)
    Someone studies his PHP daily. Great tip to everyone that's using this, I might in the future after I completely change my website around.:drool:
    adcode // ToS // x10Free | x10Paid Hosting
    ------------------------------------------

  5. #5
    Bryon is offline Administrator Bryon has disabled reputation
    Join Date
    Apr 2005
    Location
    Northfield, NH
    Posts
    7,608

    Re: Image Verification

    Haha, it's been 2 long years to get where I am. I still don't know all that much..

    And your welcome DesertWar

+ Reply to Thread

Similar Threads

  1. Replies: 1
    Last Post: 11-04-2006, 06:49 PM
  2. Homepage image 200 points!!
    By __z|x__ in forum The Marketplace
    Replies: 3
    Last Post: 06-13-2006, 06:27 PM
  3. errors while attaching
    By mattspec in forum Feedback and Suggestions
    Replies: 0
    Last Post: 12-19-2005, 01:50 PM
  4. November Desktop
    By n4tec in forum Off Topic
    Replies: 12
    Last Post: 11-08-2005, 07:18 AM
  5. Add free image hosting to your site
    By nigelwong in forum Off Topic
    Replies: 2
    Last Post: 09-19-2005, 04:57 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers