<?php
function randPass($length=6)
{
$all=explode(" ","z x c v b n m a s d f g h j k l q w e r t y u i o p"." Z X C V B N M A S D F G H J K L Q W E R T Y U I O P"." 1 2 3 4 5 6 7 8 9 0");
for($i=0;$i<$length;$i++)
{
mt_srand();
$point=mt_rand(0,61);
$passWord.=$all[$point];
}
return $passWord;
}
session_start();
session_register('getpass');
if(isset($_POST['pass']))
if ($_POST['pass']!=$getpass)
{echo '<script>alert("验证错误!");location="'.$PHP_SELF.'";</script>';}
else
{echo '<script>alert("验证正确!");location="'.$PHP_SELF.'";</script>';}
echo "验证码:".$getpass=randPass(4);
echo '<br><form name="pw" action="'.$PHP_SELF.'" method="post"><input name="pass" type="text"/><br><input type="submit" value="验证"/> <input type="submit" value="刷新"/></form>';
?>