0
私は$this->error['warning']
は、入力後のユーザー名やパスワードがある場合でも、同時に現れて続けているいくつかの理由でメンバーのログイン情報検証はISSETメッセージと同時に警告メッセージを表示さ
を検証する必要があり、ここで、このコードを持っています設定されていません。
質問パスワードとユーザー名が2番目のチェックを実行しないように設定されていないかどうかを確認するには、どちらも完了してください。
public function validate() {
/* First Checks */
if (!$this->input->post('username')) {
$this->error['username'] = 'You have missed the username input!';
}
if (!$this->input->post('password')) {
$this->error['password'] = 'You have missed password input!';
}
/* Second Checks */
if (($this->input->post('password') != '') && ($this->input->post('username') != '')) {
if (!$this->member->login($this->input->post('password'), $this->input->post('username'))) {
$this->error['warning'] = 'In correct username or password!';
}
if (!$this->member->approved($this->input->post('username'))) {
$this->error['warning'] = 'Your account not approved yet!';
}
}
return !$this->error;
}
全コントローラ
<?php
class Login extends CI_Controller {
private $error = array();
public function __construct() {
parent::__construct();
}
public function index() {
$this->data['title'] = 'Members Login';
if ($this->member->getmemberid()) {
redirect(base_url('admin/members/dashboard'));
}
if (($this->input->server('REQUEST_METHOD') == 'POST') && $this->validate()) {
redirect(base_url('admin/members/dashboard'));
}
if (isset($this->error['warning'])) {
$this->data['error_warning'] = $this->error['warning'];
} else {
$this->data['error_warning'] = '';
}
if (isset($this->error['username'])) {
$this->data['error_username'] = $this->error['username'];
} else {
$this->data['error_username'] = '';
}
if (isset($this->error['password'])) {
$this->data['error_password'] = $this->error['password'];
} else {
$this->data['error_password'] = '';
}
if ($this->input->post('username')) {
$this->data['username'] = $this->input->post('username');
} else {
$this->data['username'] = '';
}
if ($this->input->post('password')) {
$this->data['password'] = $this->input->post('password');
} else {
$this->data['password'] = '';
}
$this->load->view('admin/template/common/header', $this->data);
$this->load->view('admin/template/member/login', $this->data);
$this->load->view('admin/template/common/footer');
}
public function validate() {
if (!$this->input->post('username')) {
$this->error['username'] = 'You have missed the username input!';
}
if (!$this->input->post('password')) {
$this->error['password'] = 'You have missed password input!';
}
if (($this->input->post('password') != '') && ($this->input->post('username') != '')) {
if (!$this->member->login($this->input->post('password'), $this->input->post('username'))) {
$this->error['warning'] = 'In correct username or password!';
}
if (!$this->member->approved($this->input->post('username'))) {
$this->error['warning'] = 'Your account not approved yet!';
}
}
return !$this->error;
}
}