【发布时间】:2014-04-18 01:22:39
【问题描述】:
我正在为我的网站建立一个登录我有这个 if 语句:
$application = 'home';
$this->user_model->loggedin() == TRUE || redirect($application);
$rules = $this->user_model->_rules;
$this->form_validation->set_rules($rules);
if ($this->form_validation->run() !== FALSE) {
if ($this->user_model->login() !== FALSE) {
redirect('home');
echo 'success';
} else {
echo 'fail';
}
}
由于某种原因,当我提出条件 == FALSE 时它不会运行 else,这将输入错误的电子邮件和密码。无论哪种方式,我都会收到消息成功我在这里遗漏了什么吗?
这里是 user_model 中的登录功能,如果有帮助,想不出这个,任何帮助将不胜感激。
public function login() {
$user = $this->get_by(array(
'email_address' => $this->input->post('email_address'),
'password' => $this->hash($this->input->post('password'))
), TRUE);
if (count($user)) {
// log in user
$data = array(
'first_name' => $user->first_name,
'last_name' => $user->last_name,
'email_address' => $user->email_address,
'id' => $user->id,
'loggedin' => TRUE,
);
$this->session->set_userdata($data);
}
}
【问题讨论】:
标签: php codeigniter if-statement