Monday, 15 September 2014

php - How can i make a reset password function in codeigniter? -



php - How can i make a reset password function in codeigniter? -

whenever run code, recieve blank screen on submission. code not seem work , i'm unsure why. can see issue? i've checked syntax mutliple times.

controller:

public function changepwd(){ $this->form_validation->set_rules('oldpassword','old password','required|trim|xss_clean|callback_change'); $this->form_validation->set_rules('password1','new password','required|trim'); $this->form_validation->set_rules('password2','confirm password','required|trim|matches[password1]'); if($this->form_validation->run()= true){ redirect('admin'); }else{ $this->form_validation->set_message('change','info wrong'); redirect('admin'); } } public function change(){ $this->load->view('error_display'); $oldpass = $this->input->post('oldpassword'); if(isset($oldpass)){ if($this->input->post('password1') == $this->input->post('password2')){ $session=$this->session->userdata("logged_in"); $username= $session['username']; $query = "select * database username='$username'"; $result = $this->db->query($query); $row=$result->row(); $pass = $row->password; $s= $row->salt; $user_old_pass = sha1($s.$oldpass); if($pass == $user_old_pass){ $new = substr(uniqid(rand(), true), 0, 20); $users_password = $this->input->post('pass1'); $new_password = sha1($new.$user_password); $data = array($new,$new_password); $this->update_model->insert_model($data); $this->form_validation->set_message('change','saved'); $this->load->view('admin'); }else{ $this->form_validation->set_message('change','<p class="error">incorrect password</p>'); homecoming false; redirect('admin'); } }else{ $this->form_validation->set_message('change','passwords dont match'); homecoming false; redirect('admin'); }; }else{ $this->form_validation->set_message('change','old password not entered'); homecoming false; redirect('admin'); }

model:

function login($data) { $this->db->update('database', $data); }

your

if($this->form_validation->run()= true){

should

if($this->form_validation->run() == false) {

because redirecting every time 'admin'

php codeigniter

No comments:

Post a Comment