_request->getPost('username'); "/> _request->getPost('username'); ">
Home > Backend Development > PHP Tutorial > 登入模块 小疑点一只

登入模块 小疑点一只

WBOY
Release: 2016-06-13 10:08:23
Original
851 people have browsed it

登入模块 小问题一只

PHP code
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->if(isset($_REQUEST["username"]) && !empty($_REQUEST["password"])){        $username=$this->_request->getPost('username');        $password=$this->_request->getPost('password');        $dms = new Dms();//实例化数据库类        $db = $dms->getAdapter();          $sql = "SELECT * FROM users WHERE username='$username' AND password='$password'";            $rs = $db->query($sql);            // $rs->num_rows判断上面的执行结果是否含有记录,有记录说明登录成功            if ($rs && $rs->num_rows > 0) {                               // 在实际应用中可以使用前面提到的重定向功能转到主页               echo  "登录成功!";            }}
Copy after login

一直报错 不明白哪里不对了
[error] [client 127.0.0.1] PHP Notice: Undefined property: Zend_Db_Statement_Pdo::$num_rows in /var/www/DMS/application/controllers/LoginController.php on line 32, referer: http://dms.com/login

------解决方案--------------------
輸出一下看看
PHP code
if(isset($_REQUEST["username"]) && !empty($_REQUEST["password"])){        $username=$this->_request->getPost('username');        $password=$this->_request->getPost('password');        $dms = new Dms();//实例化数据库类        $db = $dms->getAdapter();          $sql = "SELECT * FROM users WHERE username='$username' AND password='$password'";echo $sql;//看看對不對            $rs = $db->query($sql);            // $rs->num_rows判断上面的执行结果是否含有记录,有记录说明登录成功echo $rs->num_rows;//看看對不對            if ($rs && $rs->num_rows > 0) {                               // 在实际应用中可以使用前面提到的重定向功能转到主页               echo  "登录成功!";            }}<div class="clear">
                 
              
              
        
            </div>
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template