【发布时间】:2017-02-10 11:34:17
【问题描述】:
这是我的登录表单:
<div class="form-container">
<h1 style="text-align:left">Login Here!</h1><br>
<form class="form-horizontal" action="<?php echo base_url(); ?>index.php/User_Authentication_Controller/login_user" method="POST">
<div class="error_msg1"></div>
<input autofocus="autofocus" type="text" name="txt_login_username" class="form-control" placeholder="Username.."/><div class="error_msg2"></div>
<input type="password" name="txt_login_password" class="form-control" placeholder="Password.." /><div class="error_msg3"></div>
<center><button class="btn btn-info" type="submit">Login</button><br/><br/>
<a href="<?php echo base_url();?>index.php/Pages_Controller/show_forgotpassword">Forgot Password?</a></center>
</form>
</div>
这是我的控制器:
public function login_user(){
$username = $this->input->post('txt_login_username');
$password = md5($this->input->post('txt_login_password'));
$result=$this->LogIn_Model->login($username,$password);
if (!empty($username) && !empty($password)) {
if($result!=null){
$_SESSION["username"] = $username;
$_SESSION["id"] = $result["0"]["Account_no"];
$_SESSION["Usertype"] = $result["0"]["Usertype"];
if($result["0"]["Status"] == 1){
if($result["0"]["Usertype"] == 0){
redirect('User_Authentication_Controller');
}
else if($result["0"]["Usertype"] == 1){
redirect('Pages_Controller/show_adminpage/');
}
}
else if($result["0"]["Status"] == 0){
redirect('User_Authentication_Controller');
}
}
else{
redirect('User_Authentication_Controller');
}
}
else{
redirect('User_Authentication_Controller');
}
}
这确实有效!
现在我的问题是:
正如您在else if($result["0"]["Status"] == 0){} 中看到的,我想要的只是在我提交页面后它会重定向回登录,我希望
<div class="error_msg1"></div>
会显示一个错误提示,“您的帐户已被管理员停用”如果他输入用户名,它会在他提交时保持静止!我将如何做到这一点?如果他输入用户名:Michael 并输入错误的密码,我希望用户名:Michael 保持不动!表单提交后我将如何处理?
【问题讨论】:
标签: php html codeigniter