查询未按预期执行

时间:2016-08-08 19:12:21

标签: php mysql

我正在使用用户的注册系统。这是用于激活用户帐户的URL:

http://../verify.php?id=40&code=fdc6604289e5a58fe1ab9dffa8e2f870

这是verify.php的代码:

<?php
require_once 'class.user.php';
$user = new USER();


if(empty($_GET['id']) && empty($_GET['code']))
{
    $user->redirect('index.php');
}

if(isset($_GET['id']) && isset($_GET['code']))
{
    $id = $_GET['id'];
    $code = $_GET['code'];

    $statusY = "Y";
    $statusN = "N";

    $stmt = $user->runQuery("SELECT userID,userStatus FROM tbl_users WHERE userID=:uID AND tokenCode=:code LIMIT 1");
    $stmt->execute(array(":uID"=>$id,":code"=>$code));
    $row=$stmt->fetch(PDO::FETCH_ASSOC);
    if($stmt->rowCount() > 0)
    {
        if($row['userStatus']==$statusN)
        {
            $stmt = $user->runQuery("UPDATE tbl_users SET userStatus=:status WHERE userID=:uID");
            $stmt->bindparam(":status",$statusY);
            $stmt->bindparam(":uID",$id);
            $stmt->execute();   

            $msg = "
                   <div class='alert alert-success'>
                   <button class='close' data-dismiss='alert'>&times;</button>
                      <strong>WoW !</strong>  Your Account is Now Activated : <a href='index.php'>Login here</a>
                   </div>
                   ";   
        }
        else
        {
            $msg = "
                   <div class='alert alert-error'>
                   <button class='close' data-dismiss='alert'>&times;</button>
                      <strong>sorry !</strong>  Your Account is allready Activated : <a href='index.php'>Login here</a>
                   </div>
                   ";
        }
    }
    else
    {
        $msg = "
               <div class='alert alert-error'>
               <button class='close' data-dismiss='alert'>&times;</button>
               <strong>sorry !</strong>  No Account Found : <a href='signup.php'>Signup here</a>
               </div>
               ";
    }   
}

?>
<!DOCTYPE html>
<html>
  <head>
    <title>Confirm Registration</title>
    <!-- Bootstrap -->
    <link href="bootstrap/css/bootstrap.min.css" rel="stylesheet" media="screen">
    <link href="bootstrap/css/bootstrap-responsive.min.css" rel="stylesheet" media="screen">
    <link href="assets/styles.css" rel="stylesheet" media="screen">
     <!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
    <!--[if lt IE 9]>
      <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->
    <script src="js/vendor/modernizr-2.6.2-respond-1.1.0.min.js"></script>
  </head>
  <body id="login">

    <div class="container">
        <?php if(isset($msg)) { echo $msg; }
        ?>
    </div> <!-- /container -->
    <script src="vendors/jquery-1.9.1.min.js"></script>
    <script src="bootstrap/js/bootstrap.min.js"></script>

  </body>
</html>

这是来自数据库的记录: enter image description here

问题是$ _GET ['id']和$ _GET ['code']是正确的值,但页面显示选项:NO ACCOCO FOUND ...

我正在寻找数小时的原因,但没有成功。

欢迎任何寻找问题根源的帮助

0 个答案:

没有答案