我的登录系统突然停止工作,我无法修复它,我一直在调查它,似乎数据没有被回发但是我找不到问题。
这是我的看法:
<?php if(! is_null($err)) echo "<div class=\"alert alert-danger\">".$err."</div>";?>
<form class="form-signin" action="<?php echo site_url("user/validate"); ?>" method="post">
<h2 class="form-signin-heading">Please sign in</h2>
<label for="email" class="sr-only">Email address</label>
<input type="email" name="email" class="form-control" placeholder="Email address" required autofocus>
<br/>
<label for="password" class="sr-only">Password</label>
<input type="password" name="password" class="form-control" placeholder="Password" required>
<br/>
<button class="btn btn-lg btn-primary btn-block" name="submit" type="submit">Sign in</button>
</form>
</div>
这是我在用户控制器中的验证功能:
public function validate()
{
$email = $this->input->post('email');
$password = $this->input->post('password');
// Load the model
echo "$email and $password sent";
print_r($this->input->post());
exit();
$this->load->model('User_model');
// Validate user's login details
$result = $this->User_model->validate($email, $password);
// Now we verify the result
if($result == 0){
// If user did not validate, then show them login page again
$err = 'Invalid email and/or password.';
$this->login($err);
}else{
// If user did validate send him to homepage after setting the credentials
$this->session->set_userdata($result);
redirect(site_url("/index/index"));
}
}
echo和print_r显示没有数据发布。
经过一番研究后我发现问题应该是.htaccess文件,这是我目前的.htaccess:
RewriteEngine On
RewriteRule ^(application) - [F,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
但它没有用。
答案 0 :(得分:0)
exit();
对其进行评论尝试:if(!empty( $err ))
尝试:base_url("index.php/user/validate");
尝试:在
中加载模型 public function __construct()
不在
之内 public function validate()
答案 1 :(得分:0)
<form class="form-signin" action="<?php echo site_url("user/validate"); ?>" method="post">
将此更改为以下内容:
<form class='form-signin' action="<?php echo base_url();?>user/validate" method="post" name="user_from">
也不要将提交按钮名称用作“提交”。只需使用sbt或其他名称,id也是......