Welcome Guest, Not a member yet? Register   Sign In
tank auth ant multiple forms
#1

[eluser]zgames[/eluser]
I want to be able to run multiple forms, right now i named my forms by 3 different id's, added if statement, but with this statement I can't get my errors to show up, my view file can't reach them, therefore my control panel isn't passing the information.
If i remove the
Code:
if ($this->input->post('password_change'))
it's working because my errors can show up, however then i face another problem forms on submit action validate all the forms and because most fields are required I can't change my email, i have to change my password, add new password and at the same time add new email...
any suggestions?

Code:
function controlpanel()
{
  if ($this->input->post('password_change')) {
   $this->form_validation->set_rules('old_password', 'Old Password', 'trim|required|xss_clean');
   $this->form_validation->set_rules('new_password', 'New Password', 'trim|required|xss_clean|min_length['.$this->config->item('password_min_length', 'tank_auth').']|max_length['.$this->config->item('password_max_length', 'tank_auth').']|alpha_dash');
   $this->form_validation->set_rules('confirm_new_password', 'Confirm new Password', 'trim|required|xss_clean|matches[new_password]');
   $data['errors'] = array();
  }
  
  
  
  if ($this->form_validation->run()) {        // validation ok
   if ($this->tank_auth->change_password(
    $this->form_validation->set_value('old_password'),
    $this->form_validation->set_value('new_password'))) { // success
    $this->_show_message($this->lang->line('auth_message_password_changed'));

   } else {              // fail
    $errors = $this->tank_auth->get_error_message();
    foreach ($errors as $k => $v) $data['errors'][$k] = $this->lang->line($v);
    }
   }
  
  if ($this->input->post('email_change')) {
   $this->form_validation->set_rules('password', 'Password', 'trim|required|xss_clean');
   $this->form_validation->set_rules('email', 'Email', 'trim|required|xss_clean|valid_email');
   $data['errors'] = array();
  }
  

  if ($this->form_validation->run()) {        // validation ok
   if (!is_null($data = $this->tank_auth->set_new_email(
    $this->form_validation->set_value('email'),
    $this->form_validation->set_value('password')))) {   // success
    $data['site_name'] = $this->config->item('website_name', 'tank_auth');

    // Send email with new email address and its activation link
    $this->_send_email('change_email', $data['new_email'], $data);
    $this->_show_message(sprintf($this->lang->line('auth_message_new_email_sent'),         $data['new_email']));

   } else {
    $errors = $this->tank_auth->get_error_message();
    foreach ($errors as $k => $v) $data['errors'][$k] = $this->lang->line($v);
      }
  }
  
  
  if ($this->input->post('delete_user')){
   $this->form_validation->set_rules('password', 'Password', 'trim|required|xss_clean');
   $data['errors'] = array();
   }

  

   if ($this->form_validation->run()) {
    $this->load->view('auth/controlpanel_form', $data);       // validation ok
    if ($this->tank_auth->delete_user(
      $this->form_validation->set_value('password'))) {  // success
     $this->_show_message($this->lang->line('auth_message_unregistered'));

    } else {              // fail
     $errors = $this->tank_auth->get_error_message();
     foreach ($errors as $k => $v) $data['errors'][$k] = $this->lang->line($v);
    }
   }

      $this->load->view('auth/controlpanel_form', $data);

  
}




Theme © iAndrew 2016 - Forum software by © MyBB