2016-09-21 3 views
-1

私は常にcodeigniterでencryptとdecrytpを使用します。今私は私のために働いていないajax解読を使用してログインしようとしています。私のコーディングは、私が間違ったテーブル名パスワードショー0を与えて、コンソールをチェックしたときに、これは$this->encrypt->decode($this->input->post('password'))が私のために働いていないことなど暗号化がAjaxで動作しない

<?php 
public function CheckLogin(){ 
     $this->input->post('password'); 
     $password = $this->encrypt->decode($this->input->post('password')); 
     if($this->input->post('profile') == 'distributer'){ 
       $Response = $this->db->get_where($this->db->dbprefix."distsributer_account",array('username'=>$this->input->post('username'),'password'=>$password,'status'=>'Y'))->result(); 
     } 
     if($this->input->post('profile') == 'retailer'){ 
       $Response = $this->db->get_where($this->db->dbprefix."Sefnder",array('Username'=>$this->input->post('username'),'Password'=>$password,'status'=>'Y'))->result(); 
     } 
} 
?> 

を下回っています。私はすでに入力 - >の$ this - の値をチェックし

>ポスト(「パスワード」)が正常に動作している

私返されたSQLクエリは、この

SELECT * FROM `flip_distsributer_account` 
WHERE `username` = '[email protected]' 
AND `password` =0 
AND `status` = 'Y' 
+0

暗号化ライブラリを読み込みましたか? –

+0

私は暗号化ライブラリを読み込みました。このコードをajaxで実行すると、このタイプの問題に直面しています –

+0

CSRF保護が使用されていますか? – Tpojka

答えて

0

あるユーザー名で検索すると、保存されたパスワードを解読した後にパスワードを一致させます。

<?php 
public function CheckLogin(){ 
     $password = $this->input->post('password'); 
     if($this->input->post('profile') == 'distributer'){ 
      $Response = $this->db->get_where($this->db->dbprefix."distsributer_account",array('username'=>$this->input->post('username'),'status'=>'Y'))->row_array(); 
      if($this->encrypt->decode($Response['password']) == $password)   { 
      echo "Password is equal"; 
     } 
     } 
     if($this->input->post('profile') == 'retailer'){ 
       $Response = $this->db->get_where($this->db->dbprefix."Sefnder",array('Username'=>$this->input->post('username'),'status'=>'Y'))->result(); 
     } 
} 
関連する問題