Zend Framework登录密码验证

时间:2014-07-28 07:35:21

标签: php mysql zend-framework

Havin表示将电子邮件和密码发送到.php文件以检查用户是否存在于数据库中。

login_form.php如下

// define variables and set to empty values
$email_login = $password_login = $gender = $comment = $website = "";

if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $email_login = test_input($_POST["email_login"]);
    $password_login = test_input($_POST["password_login"]);
}

function test_input($data) {
 $data = trim($data);
 $data = stripslashes($data);
 $data = htmlspecialchars($data);
 return $data;
}

在课程的下面一行中检查

$sql = new Sql($this->adapter);
    $select = $sql->select();   
    $projectTable = new TableGateway('users', $this->adapter);      

    $rowset = $projectTable->select(array(
                                    //'email' => $this->email_login,
                                    'password' => $this->password_login,    
                                    ));
    $curRowSet = $rowset->current();
    foreach($curRowSet as $echoRow)
    {
        echo $curRowSet->id." ".$curRowSet->email." ".$curRowSet->username." ".$curRowSet->password."<br>";
    }

其中

  1. $ this-&gt; adapter与数据库建立Zend Db Adapter连接
  2. 表的名称是用户,有4行

     id
     username
     email
     password
    
  3. 回显所有找到的值以测试是否找到任何匹配和

    $this->password_login = hash('whirlpool', $this->password_login);
    

    是不是因为从MySql Db密码也像这样散列。但是出现以下错误&gt;

      

    第83行的C:\ xampp \ htdocs \ bootSite \ check \ login_form.php中为foreach()提供的参数无效

    当我改变

    //'email' => $this->email_login,
    'password' => $this->password_login,    
    

      'email' => $this->email_login,
    //'password' => $this->password_login,  
    

    有4个相同值的回波。电子邮件也是独一无二的。

    我的问题出现了:如何比较2个哈希密码,一个来自$ _POST变量另一个来自MySql Db表?

0 个答案:

没有答案
相关问题