title: Reset password function in php codeigniter
body: <p>I am trying to write reset password function in codeigniter php and mind mind not clicking where to start and what is the best way to do so pls help</p>
  
  <pre><code>my db as like this
  CREATE TABLE `members` (
   `id` int(11) NOT NULL AUTO_INCREMENT,
   `username` varchar(255) NOT NULL,
   `email` varchar(255) NOT NULL,
   `password` varchar(255) NOT NULL,
   `verifystring` varchar(15) NOT NULL,
   `lostkey` varchar(100) NOT NULL,
   `active` enum('0','1') NOT NULL,
   PRIMARY KEY (`id`)
  ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=latin1
  </code></pre>
  
  <p>and function goes like this </p>
  
  <p>//forget password</p>
  
  <pre><code> public function forget_password(){
  
      $this-&gt;form_validation-&gt;set_rules('email','Email Address','xss_clean|required|valid_email|callback_reset_password');
      if($this-&gt;form_validation-&gt;run() == FALSE){
      $this-&gt;load-&gt;view('account/forget_password');
      }else{
  
          //send an email
          $this-&gt;load-&gt;library('email');
          $this-&gt;email-&gt;set_newline("\r\n");
  
              $this-&gt;email-&gt;from('me@gmail.com', 'Raju');
              $this-&gt;email-&gt;to('me@gmail.com');
              $this-&gt;email-&gt;subject('Email my');
              $key = 12334455;
              $message = "Please click this url to change your password ". base_url()."reset_now/".$key ;
              $message .="&lt;br/&gt;Thank you very much";
              $this-&gt;email-&gt;message($message);
  
          if($this-&gt;email-&gt;send())
                  {
                      echo 'Please check your email to reset password.';
                  }
  
                  else
                  {
                      show_error($this-&gt;email-&gt;print_debugger());
                  }
      }
  
  }
  
  
  //email check for forget password
  function reset_password($email){
      $query = $this-&gt;db-&gt;get_where('members', array('email'=&gt;$email));
  
      if(!$query-&gt;num_rows()&gt;0){
          $this-&gt;form_validation-&gt;set_message('forget_email_check', 'The %s does not exists in our database');
          return FALSE;
      }else{
  
          //check database fields
          /*
          $this-&gt;db-&gt;where('email', $email);
          $this-&gt;db-&gt;limit(1);
          $Q = $this-&gt;db-&gt;get('members');
          if($Q-&gt;num_rows()&gt;0){
              $data = $Q-&gt;result_array();
  
              echo $data[0]['username'].'&lt;br/&gt;';
              echo $data[0]['password'].'&lt;br/&gt;';
          }
  
      */
  
          echo '&lt;br/&gt;'. $email.'&lt;br/&gt;';
      }
  
      //$query-&gt;free_result();
      //return true;
  }
  </code></pre>