语音校验码中验证问题求助 新手求高手指教 急急!!!

kate_jy 发布于 2011/05/10 23:32
阅读 326
收藏 1

user.php
<?php
@session_start();
$user=new user();
if(isset($_GET["action"])){
    switch(strval($_GET["action"])){
        case"register":
            $user->register();
        break;
        case"login":
            $user->login();
        break;
    }
}else{
    $user->auth();
}
class user{
    function login(){
        $name=strval($_POST["username"]);
        $pass=strval($_POST["password"]);
        $code=strval($_POST["vercode"]);
        if($code!=$_SESSION["string"]){
            echo"请输入正确的认证码<br><br>".
              "<a href='javascript:history.go(-1);'>返回上一步</a>,或等待页面自动跳转,请稍后. . .".
              "<script>setTimeout('history.go(-1)',3000);</script>";
              exit();
        }
      
        include_once("F:\CAPTCHA\adodb511\adodb5/abodb.inc.php");
        $conn = &ADONewConnection('db'); 
        $conn->Connect("localhost","root","123456","db");
        $sql="select id,username,password,role from user where username='".$name."'and password='".md5($pass)."'";
        $row=$conn->Execute($sql);
        $conn->close();
        if($row->RecordCount()==1){
            $detail=$row->FetchRow();
            $_SESSION["auth"]["name"]=$detail[1];
            $_SESSION["auth"]["pass"]=$detail[2];
            $_SESSION["auth"]["role"]=$detail[3];
            echo "登录成功<br><br>".
              "<a href='user1.php'>进入用户界面</a>,或等待页面自动跳转,请稍候。。。".
              "<script>setTimeout('window.location.href=\"user1.php\"',3000);</script>";
              exit();
              }else{
                echo"用户名或密码错误<br><br>".
                    "请改正错误后,重试!<br><br>".
                    "<a href='javascript:history.go(-1);'>返回上一步</a>,或等待页面自动跳转,请稍后。。。".
                    "<script>setTimeout('history.go(-1)',3000);</script>";
                    exit();
              }
      }
      function auth(){
        exit("非法调用,程序终止运行!");
      }
}
?>
88888888888888888888888888888888888
voice_code.php
<?PHP
/* vim: set expandtab tabstop=4 shiftwidth=4 foldmethod=marker: */
/**
 * @Name       voice_code.php
 * @Note       语音验证码
 **/

header('Content-type: audio/mpeg');

//随机种子
list($usec, $sec) = explode(' ', microtime());
/**
 * 按空格把微秒数和时间戳拆开成一个数组,因为microtime()返回的字符串是以空格为分隔符.
 * 得到的是一个类似Array ( [0] => 0.57812900 [1] => 1286935327 ) 的数组
list($usec, $sec) //list — 把数组中的值赋给一些变量 ,按数组下标顺序赋值. 
得到类似:
$usec = 0.57812900;
$sec = 1286935327;
 */
$randtime =  (float) $sec + ((float) $usec * 100000);
srand($randtime);
//随机验证码
$authnum = '';
//$str = 'abcdefghijkmnpqrstuvwxyz1234567890';
$str = '1234567890';
$l = strlen($str);
for($i=0;$i<4;$i++)
{
    $num=rand(0,$l);
    $authnum.= $str[$num];
}
//把随机验证码记录到session
$_SESSION['auth_code'] = $authnum;
//转成字符串,方便用数组调用
$code = strval($authnum);

//readfile("sound/begin.mp3");
for($i=0;$i<strlen($code);$i++)
{
    $soundNum = $code[$i];
    readfile("sound/$soundNum.mp3");
}
//readfile("sound/end.mp3");
?>

888888888888888888888888888888888888
登录.html
<html>

<head>
	    <title>用户登录</title>
</head>

<body>

<form id="login" name="login" method="post" action="user.php? action=login">
 <table border=0 align="center" cellpadding=0 cellspacing=5>
 <tr>
   <td><div align=right>用户名:</div></td>
   <td><label>
     <input type="text" name="user"/>
      </label> </td>
 </tr>
 <tr>
   <td><div align=right>密码:</div></td>
   <td><label>
   <input type="password" name="password"/>
   </label></td>
 </tr>
 <br/>
 <br />
 <tr>
   <td><div align=right>认证码:</div></td>
   <td>
   <script language="javascript">
var myimages=new Array();
function preloadimages()
{
    for (i=0;i<preloadimages.arguments.length;i++)
    {
        myimages[i]=new Image();
        myimages[i].src=preloadimages.arguments[i]
    }
}
preloadimages("sound/audio.jpg");
</script>
</head>
<body>
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="0" height="0" id="code_play" align="middle">
<param name="allowScriptAccess" value="always" />
<param name="FlashVars" value="url=voice_code.php" />
<param name="movie" value="code_play.swf"/>
<param name="quality" value="high" />
<param name="bgcolor" value="#ffffff" />
<embed id="code_play" name="code_play" src="code_play.swf"  FlashVars="url=voice_code.php" quality="high" bgcolor="#ffffff" width="0" height="0" align="middle" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object>
<script language="javascript">
function readVoiceCode()
{
    document.getElementById('code_img').src = "sound/audio.jpg";
    document.getElementById('againListen').style.display='';
    document.getElementById('readVoiceBtn').style.display='none';
    window.document.code_play.SetVariable("isPlay", "1");
}
</script>
<a href="javascript:void(0);" onclick="javascript:readVoiceCode();" id="readVoiceBtn">读语音验证码</a>
<a href="javascript:void(0);" onclick="javascript:readVoiceCode();" id="againListen" style="display:none;">没听清?再听一次</a>
<img src='sound/default.jpg' id="code_img">
   <!-- <div>
      <h4 align="center"><object  classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="200" height="20"
    codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab">
    <param name="allowScriptAccess" value="always" />
    <param name="FlashVars" value="url=voice_code.php" />
    <param name="movie" value="singlemp3player.swf?showDownload=false" />
    <param name="wmode" value="transparent" />
    <embed wmode="transparent" width="200" height="20" src="singlemp3player.swf?showDownload=false"  FlashVars="url=voice_code.php"
      type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object>
</h4>-->   <!--<img src='23.php'/>-->
    <input type="text" name="vercode" />
    </td>
 </tr>
 <tr>
   <td colspan="2"><label>
     <div align=center>
      <input type="submit" name="Submit" value="登录" />
      </div>
   </label></td>
 </tr>
 </table>
 </form>
</body>
</html>
我用的软件是phpdesiger和webserver, 运行文件后,语音读出正常,当输入正确的校验码登录后显示的的是请输入正确的认证码,
也就是我的程序认为我输入的校验码都是错的,请认真看红色的部分,是不是那里出现错误了,请高手指点。
加载中
0
kate_jy
kate_jy

咋这么冷清呢 咋没人理我呢  大手别麻烦啊 帮帮啊

返回顶部
顶部