|
<? Php
/*
* File: chinesechar. php
* Role: storage of Chinese character data
*/
$ ChineseChar = array ("person", "out", "come", "friend", "", "filial piety", "benevolence", "righteousness ", "Li", "Lian", "Zhong", "Guo", "Zhong", "Yi", "White", "man", "fire", "Earth ", "gold", "Wood", "lei", "wind", "dragon", "Tiger", "day", "Earth", "Sheng", "Dizzy ", "Dish", "bird", "Tian", "3", "bai", "Qian", "Fu", "love", "Emotion", "Beast ", "Insects", "fish", "Nine", "Net", "new", "degree", "Ah", "Alas", "Ah", "Oh ", "Yi", "old", "shao", "day", "month", "Star ");
?>
<? Php
/*
* File: check. php
* Function: Verification
*/
Session_start ();
$ ErrorMSG = '';
// Verify that the user input is consistent with the verification code
If (! Is_null ($ _ POST ['check'])
{
If (strcasecmp ($ _ SESSION ['code'], $ _ POST ['code']) = 0)
$ ErrorMSG = "<p style =" font-size: 12px; color: #009900 "> Verification Successful! </P> ";
Else
$ ErrorMSG = "<p style =" font-size: 12px; color: # FF0000 "> Verification Failed! </P> ";
}
?>
<Html>
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312">
</Head>
<Body>
<? Php
If ($ errorMSG ){
Echo $ errorMSG;
}
?>
<Form action = <? Php echo $ _ SERVER ['php _ SELF ']?> Method = post>
Enter the verification code: <input type = "text" name = "code" style = "width:
80px ">
<Br>
<Input type = "submit" name = "check" value = "submit verification code">
</Form>
</Body>
</Html>
<? Php
/*
* File: code. php
* Function: generate a verification code
* Special Note: All copyrights are copyrighted by grass without teeth! Gains can be gained only when you have paid!
*/
Include_once ("chinesechar. php ");
Session_start ();
// Set content-type
Header ("Content-type: image/png ");
// Create an image
$ Im = imagecreatetruecolor (120, 30 );
// Create a color
$ Fontcolor = imagecolorallocate ($ im, 255,255,255 );
$ Bg = imagecolorallocate ($ im, 0, 0, 0 );
// Set text
For ($ I = 0; $ I <4; $ I ++) $ text. = $ ChineseChar [(array_rand ($ ChineseChar)];
$ _ SESSION ['code'] = $ text;
// Set the font
$ Font = 'simkai. ttf ';
// Add text
Imagettftext ($ im, 18, 0, 11, 21, $ fontcolor, $ font, iconv ("GB2312", "UTF-8", $ text ));
// Output image
Imagepng ($ im );
Imagedestroy ($ im );
?> |