Sunday 15 May 2011

Codeigniter - Array dont work correctly -


Whenever I call this function, I get user_id correctly but the password is not checked. ..

Model:

  & lt ;? Php class extends Prometheus_model CI_Model {var $ tables = array ('bots' = & gt; bots',' users' = & gt; 'user'); Function __ composition () {origin: __ creation (); } Public function tablename ($ table = NULL) {if (! Isset ($ table)) FALSE return; Return $ this- & gt; Tables [$ table]; } Get public function ($ table, $ where = array), $ command = zero) {$ this-> Db- & gt; Where ($ where); If (isset ($ command)) {$ this-> Db- & gt; Order_b ($ command); } $ Q = $ this- & gt; Db- & gt; Get_where ($ this-> tablain ($ table), $ where); $ Result = $ q- & gt; Result_are (); // If you want to find the number of rows returned, type $ q-> Num_rows () should be used ($ q-> num_rows ()) {return result [0]; } Return result; } Public Function Updates ($ table, $ where = array (), $ data) {$ this- & gt; Db- & gt; Update ($ - $ -> Tableline ($ table), $ data, $ where); Return $ $-> Db- & gt; Affected_ro (); } Enter public function ($ table, $ data) {$ this- & gt; Db- & gt; Insert ($ -> - $ tablename ($ table), $ data); Return $ the-> gt; & Gt; Insert_id (); } Delete Public Function ($ table, $ where = array)) {$ this- & gt; Db- & gt; Delete ($ this- & gt; tablename ($ table), $ where); Return $ $-> Db- & gt; Affected_ro (); } Public Work Explicit ($ query) {$ q = $ this- & gt; Db- & gt; Query ($ query); If (is_object ($ q)) {return $ q- & gt; Result_are (); } And {return $ q; }} Public function num_rows ($ table, $ where = faucet) {if (isset ($ where)) {$ this- & gt; Db- & gt; Where ($ where); } $ Q = $ this- & gt; Db- & gt; Get ($ table); Return $ q- & gt; Num_rows (); } Public function get_bot_data_by_hw_id ($ bot_hw_id) {$ q = $ this- & gt; Obtain ('bots', array ('bot_hw_id' => gt; $ bot_hw_id)); Return $ q; } Public function check_user_data ($ user_incredials, $ user_password) {if ($ this- & gt; num_rows ('user', array ('user_name' = & gt; $ user_incredials, 'user_password' = & gt; $ - this- & Gt; Encryption-> Decode ($ user_password)) == 1) Get {$ q = $ this- & gt; ('user', array ('user_name' => $ this->   

My function-calling on the controller:

  & lt ;? Php if (! Defined ('BASEPATH')) Exit ('no direct script access is allowed'); Class log No CI_Controller {Public Function Index () (if ($ -> This-> Input-> Post ('user_login')) increases {var_dump ($ this-> Prometheus_model-> Check_user_data ( $ ---> Input- & Gt; Post ('user_incredials'), $ this-> Input- & gt; Post ('user_password')));} $ this-> Load-> View ('Login_index');}}   

How can I fix this?

check_user_data () the method you are using

  if ($ this-> num_rows ('user', array ('user_name' = & gt; $ user_incredials, 'user_password   

I think that ( Logical) The following code is

    

code> $ this-> encrypt-> decode ($ user_password)

  $ this-> encrypt-> encoding (because you're calling the  num_rows ()  method and it  
  Public function num_rows ($ table, $ user_password)   

$ where = faucet) (Isset ($ where)) {$ this-> db-> where ($ where);} $ Q = $ this-> db- & gt; get ($ table); return $ q -> num_rows ();}

which is actually asking some such questions to the database, for example,

  select from the user * Where user_name = 'heera' and password = decode ('abcde12345')   

In this case, the password you are trying to match needs to be encrypted Encode (not decoded) method, because the user gives you a non-encrypted The password is given and the password saved in the database has already been encrypted, so to match with the already encoded password, plain password by using the encode method before the query before the database Encoding

No comments:

Post a Comment