visual confirmation system

Visual Confirmation System

Submitted by GHS, Mar 2007.
This tutorial will explains how to put a visual confirmation in your register form.



In somewhere on page of form, add:
Code:
  1. /* generating the random number */
     
  2. $rand = rand(11111,99999);
     

  3.  
  4. /* generating the image */
     
  5. if (isset($_GET[‘mode’] && $_GET[‘mode’] == ‘image’)
     
  6. {
     
  7.  session_start();
     
  8.  $_SESSION[‘code’] = md5($rand);
     
  9.  $img = imagecreate(50, 20);
     
  10.  $bkg = imagecolorallocate($img, 0, 0, 0);
     
  11.  $color = imagecolorallocate($img, 255, 255, 255);
     
  12.  imagestring($img, 5, 2, 2, $rand, $color);
     
  13.  header(‘Content-type:image/gif’);
     
  14.  imagegif($img);
     
  15.  imagedestroy($img);
     
  16.  exit;
     
  17. }
     

  18.  
  19. ?>
     

  20.  
  21.  
    Visual Confirmation

     

  22.  

     

  23.  

     

  24.  

     

  25.  

Now in other file (specified on

before the fields of form) add:

Code:
  1. session_start();
     

  2.  
  3. $field = isset($_POST[‘visualconfirm’]) ? $_POST[‘visualconfirm’] : ”;
     

  4.  
  5. if (md5($field) == $_SESSION[‘code’])
     
  6. {
     
  7.  // action doed if confirmation code filled on field is correct
     
  8. }
     
  9. else
     
  10. {
     
  11.  // action doed if confirmation code filled on field is incorrect
     
  12. }
     

  13.  
  14. ?> 
P.S.: Don’t forgot that you must put the submit button in your form.

Share this tutorial

If you want to show this tutorial to someone else please use following code to link to this tutorial:

HTML Link:
Visual Confirmation System” class=”text” onclick=”this.focus(); this.select();”/>
Forum BBCode:

Content of this tutorial may not be published anywhere else without author’s permission. Please link to this page instead.