When the user tries to login with out filling in any information I would like to display message You have missing input Username or Password.
Currently the validation method i use only displays error if username or password does not match database records.
How can I use both?
public function validate() {
$this->load->library('user');
$username = $this->input->post('username');
$password = $this->input->post('password');
if (!isset($username) || !isset($password) || !$this->user->login($username, $password)) {
$this->error['warning'] = 'The login information is incorrect!';
}
return !$this->error;
}
public function validate() {
$this->load->library('user');
$username = $this->input->post('username');
$password = $this->input->post('password');
if($username!='' && $password!='' ){
if (!isset($username) || !isset($password) || !$this->user->login($username, $password)) {
$this->error['warning'] = 'The login information is incorrect!';
}
}else{
$this->error['warning'] = 'Information incorrect!';
}
return !$this->error;
}
Ps:-But it's better to handel such errors as client side with javascript because it may increase the load on server :-)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With