我正在使用codeigniter 3.0.4。这里这个动作发送到控制器(first.php)没有验证任何它将转向else语句并再次显示登录页面(设置为重定向('欢迎) / login_page&#39);)。我的寄存器功能在同一个控制器上运行良好。什么是确切的问题..请帮助我找到它。谢谢。
..............控制器(first.php).....
public function signup_validation(){
$this->load->library('form_validation');
$this->form_validation->set_rules('email', 'Email', 'required|trim|xss_clean|valid_email|callback_validate_credentials');
$this->form_validation->set_rules('password', 'Password', 'required|md5|trim');
if($this->form_validation->run() ){
$user_id= $this->model_users->get_id($this->input->post('email'));
$user_status = $this->model_users->get_status($this->input->post('email'));
$data = array (
'user_id' => $user_id,
'email' => $this->input->post('email'),
'user_status' =>$user_status,
'is_logged_in' => 1
);
$this->session->set_userdata($data);
}
if ($this->session->userdata('user_status')=='0') {
redirect('main/admins');
}
elseif ($this->session->userdata('user_status')=='1') {
redirect('main/members');
}else{
redirect('welcome/login_page');
}
}
public function validate_credentials(){
$this->load->model('model_users');
if($this->model_users->can_log_in() ){
return TRUE;
} else {
$this->form_validation->set_message('validate_credentials', 'Invalid useername(email-id) or password. !');
return FALSE;
}
}
....视图(login.php)......
echo form_open("first/signup_validation");
echo'<div class="row">';
echo'<div class="form-group col-md-6 col-xs-12 col-sm-6">';
echo'<label for="email">Email<span></span></label>';
echo'<input type="text" class="form-control" id="email">';
echo'</div>';
echo'<div class="form-group col-md-6 col-xs-12 col-sm-6">';
echo'<label for="password">Password<span></span></label>';
echo'<input type="password" class="form-control" id="password">';
echo'</div>';
echo'</div>';
$data2 = array(
'class' => 'btn btn-default',
);
echo form_submit($data2, 'Login');
echo form_close('');
?>
答案 0 :(得分:0)
public void UpdateDepartmentsSettings(DepatmentsSettingsDto depatmentsSettings)
{
using (var transaction = new TransactionScope(TransactionScopeOption.RequiresNew
, new TransactionOptions {IsolationLevel = IsolationLevel.Serializable}))
{
foreach (var departmentSetting in DepatmentsSettingsDto.DepartmentSettings)
{
var currentSetting = _context.DepartmentSettings.Find(departmentSetting.Id)
if departmentSetting.Modified(currentSetting)
{
var newSetting = Mapper.Map<DepartmentSettingDto, DepartmentSetting>
(departmentSetting, currentSetting);
Mapper.Map(currentSetting, newSetting);
}
}
_context.SaveChanges();
transaction.Complete();
}
}
您的echo '<input type="text" class="form-control" id="email">';
元素不包含input
属性。 name
是用作验证规则中标识符的内容。
name
这样做......
$this->form_validation->set_rules('email'... // <- 'email' is the name attribute