Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

php - Codeigniter - matching user entered password to hashed password stored in DB always returns false. Please help -


i have controller setup join_model , login_model

a user registers , after have passed validation , captcha etc , have clicked submit set setup.

my setup controller loads join_model , create() method, takes post data , gets ready send db. when password entered in signup form get's hashed, salted etc.

after have if statement checks whether user passed checklogin method in login_model true. method in setup controller , called loginvalidated.

if true user re-directed member area (dash).

when test keep getting sent failed page. changed if state (!this->loginvalidated()) , de-directed account area meaning passwords must not match.

i wondering if have quick through code see if spot i'm going wrong?

<?php   class setup extends controller {      public function index() {          $this->load->model('join_model');         $this->join_model->create();         if ($this->loginvalidated()) { //if user credentials passed validation          redirect('dash'); //forward dashboard         }         else {             redirect('failed');         }     }     public function loginvalidated() {         $this->load->model('login_model'); //load login_model model         $this->login_model->checklogin(); //load checklogin method      }  }    <?php //my controller  class login_model extends ci_model {      public function checklogin() {             return join_model::$u;              $this->db->where('email', $this->input->post('email')); //compare db email email entered in form             $this->db->where('password', $u->password); //compare db password password entered user after hashing             $query = $this->db->get('user'); // above info 'user' table              if ($query->num_rows == 1) { //if number of rows returned 1              $this->load->library('session');             $this->session->set_userdata('user_id',$u->id);             $this->session->set_userdata('username',$u->username);             $this->session->set_userdata('first_name',$u->first_name);             $this->session->set_userdata('last_name',$u->last_name);             $this->session->set_userdata('logged_in', 'true');              return true;       }    } }   <?php // join model  class join_model extends ci_model {     public static $u;     public function create() {                 $this->load->helper('date');                 $this->load->library('encrypt');    $u->first_name = $this->input->post('first_name');                 $u->last_name = $this->input->post('last_name');                 $u->email = $this->input->post('email');                  // sha1 , salt password                 $salt = $this->config->item('encryption_key');   $password = $this->encrypt->sha1($this->input->post('password'));                 $start_hash = sha1($salt . $password);                 $end_hash = sha1($password . $salt);                 $hashed = sha1($start_hash . $password . $end_hash);                 $u->password = sha1($hashed);                  $u->birthday = $this->input->post('year') . '-' . $this->input->post('month') . '-' . $this->input->post('day');                 $u->sex = $this->input->post('sex');                  $u->created_at = date('y-m-d h:i:s', now()); // date , time user joined website                  $this->db->insert('user', $u);      } } 

my ci bit rusty, looks returning on first line of checklogin() function, seem me code below not getting executed then.

also, need hash password again before send database, otherwise comparing clear text password hash.

also, seems me you'd need user controller , model, not model user registration , login. furthermore should refrain loading libraries inside model, considered ugly when working mvc framework.


Comments

Popular posts from this blog

c# - Usage of Server Side Controls in MVC Frame work -

cocoa - Nesting arrays into NSDictionary object (Objective-C) -

ios - Very simple iPhone App crashes on UILabel settext -