This is the simplest image verification code: Image. php
- Header ("Content-type: image/png ");
- $ String = "abcdefghijklmnopqrstuvwxyz0123456789 ";
- For ($ I = 0; $ I <6; $ I ++ ){
- $ Pos = rand (0, 36 );
- $ Str. = $ string {$ pos };
- }
- $ Img_handle = ImageCreate (60, 20) or die ("Cannot Create image ");
- // Image size (x, y)
- $ Back_color = ImageColorAllocate ($ img_handle, 255,255,255 );
- // Background color RBG
- $ Txt_color = ImageColorAllocate ($ img_handle, 0, 0, 0 );
- // Text Color RBG
- ImageString ($ img_handle, 31, 5, 0, $ str, $ txt_color );
- Imagepng ($ img_handle );
- Session_start ();
- $ _ SESSION ['IMG _ number'] = $ str;
- ?>
Form. php
- Php implements simple image verification code
- More 0
- Php
- Verification code
- This is the simplest image verification code:
- Image. php
- Header ("Content-type: image/png ");
- $ String = "abcdefghijklmnopqrstuvwxyz0123456789 ";
- For ($ I = 0; $ I <6; $ I ++ ){
- $ Pos = rand (0, 36 );
- $ Str. = $ string {$ pos };
- }
- $ Img_handle = ImageCreate (60, 20) or die ("Cannot Create image ");
- // Image size (x, y)
- $ Back_color = ImageColorAllocate ($ img_handle, 255,255,255 );
- // Background color RBG
- $ Txt_color = ImageColorAllocate ($ img_handle, 0, 0, 0 );
- // Text Color RBG
- ImageString ($ img_handle, 31, 5, 0, $ str, $ txt_color );
- Imagepng ($ img_handle );
- Session_start ();
- $ _ SESSION ['IMG _ number'] = $ str;
- ?>
- Form. php
Result. php
- Session_start ();
- If ($ _ SESSION ['IMG _ number']! = $ _ POST ['num']) {
- Echo 'the number you entered doesn' t match The image.
- Try Again
';
- } Else {
- Echo 'the numbers Match!
- Try Again
';
- }
- ?>
|