[eluser]R_Nelson[/eluser]
I have a simple Login.php
Code:
<fieldset>
<legend>Personal Information</legend>
<ul class="errors">
<?php
$this->form_validation->set_error_delimiters('<li>', '</li>');
echo validation_errors(); ?>
</ul>
<?php
echo form_open('user/validate_login');
echo '<label>Username</label><br>';
echo form_input('username','');
echo '<label>Password</label>';
echo form_password('password','');
echo form_submit('submit','Login');
echo anchor('user/register','Register');
?>
</fieldset>
the function Validate_login
Code:
function validate_login()
{
$this->load->model('user_model');
$this->form_validation->set_rules('username', 'Username', 'trim|required');
$this->form_validation->set_rules('password', 'Password', 'trim|required');
if($this->form_validation->run() == FALSE)
{
$this->index();
}else{
$query = $this->user_model->validate();
if($query) // if true
{
redirect('home');
}else{
$this->form_validation->set_message('','User Name & Password do not Match');
$this->index();
}
}
}
and the User_model
Code:
function validate()
{
$this->db->where('username',$this->input->post('username'));
$this->db->where('password',md5($this->input->post('password')));
$query = $this->db->get('user');
if($query->num_rows == 1)
{
foreach ($query->result() as $row)
{
$data = array(
'username' => $this->input->post('username'),
'id' => $row->id,
'name' => $row->first_name.' '.$row->last_name,
'user_level' => $row->user_level,
'is_logged_in' => true
);
$this->session->set_userdata($data);
}
return true;
}else{
return false;
}
}
now to the question
the line
Code:
$this->form_validation->set_message('','User Name & Password do not Match');
in the controller i want that to display in the validation_errors on the form what do i need to put between the '' to get it to display or do i need to extend the form validation and have it do a DB check to see if they are there?