⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

codeigniter form validation problem



casachit
  • profile picture
  • Member

Posted 28 August 2012 - 06:56 AM

I dunno what's wrong with my code... form validation is not showing error message..
Can anyone help me as fast as possible??

here's my code of my controller

function forgotpassword()
{
$this->load->model('pages_model');
$this->form_validation->set_rules('username', 'Username', 'trim|xss_clean|required|callback_user_check');
if($this->form_validation->run() == FALSE)
{
$menu->train=$this->pages_model->fetch_training_menu();
$menu->hds=$this->pages_model->fetch_handouts_menu();
$menu->stg=$this->pages_model->fetch_guides_menu();
$menu->send="";
$this->load->view('pages/fpass',$menu);
}
else
{
$menu->train=$this->pages_model->fetch_training_menu();
$menu->hds=$this->pages_model->fetch_handouts_menu();
$menu->stg=$this->pages_model->fetch_guides_menu();
$mail=$this->pages_model->user_details_email();
$this->load->view('pages/fpass',$menu);

}
}


function user_check()
{
$this->_username = $this->input->post('username');
$query = $this->db->get_where('users', array('user_username' => $this->_username, 'user_role_id >' => 2));
if($query->num_rows()==0)
{
$this->form_validation->set_message('user_check', 'Invalid Username!');
return FALSE;
}
return TRUE;
}


here's my code for view


<?php echo $this->load->view('pages/includes/header'); ?>
<?php echo $this->load->view('pages/includes/nav'); ?>
<div id="main-content">
<div class="container group">
<div class="newlogin-inner">
<h2>Forgot Password</h2>
<div class="block newloginblock">
<?php
$attributes = array('class' => 'group', 'id' => 'login-form');echo form_open('forgotmypassword', $attributes);
if($send==""){echo $send;}else{echo '<div class="success">'.$send.'</div>';}
echo validation_errors('<div class="error">', '</div>');
?>
<label for="username">Enter Your Username:</label>
<?php echo form_input('username', '', 'class="frm-input username"');?>
<?php
$data = array(
'class' => 'frm-button alignright',
'value' => 'Submit',
'type' => 'submit',
'content' => 'Submit'
);
echo form_button($data);echo form_close();
?>
</form><!-- #forgotpassword-form -->
</div>
</div>
</div><!-- container -->
</div><!-- #main-content -->
<?php echo $this->load->view('pages/includes/footer'); ?>

noskov.biz
  • profile picture
  • Member

Posted 31 August 2012 - 11:45 AM

Hi, casachit!
Function user_check() doesn't have any parameter.