[eluser]huskyfritz[/eluser]
Hi, I have a small CI app deployed in my localhost and it works fine. I am planning to deploy it in a web server but I always get an error "An Error Was Encountered. The action you have requested is not allowed.". I have a login form and when I try to validate the user, the said problem will appear.
Here's my little code:
login controller
Code:
function validate_User(){
// utilize validation helper
$this->form_validation->set_rules('username','Username','trim|required|max_length[5]');
$this->form_validation->set_rules('password','Password','trim|required|max_length[32]');
if($this->form_validation->run() == FALSE){
$data_array = array('dashboard_msg' => validation_errors());
$this->session->set_flashdata($data_array);
redirect('login');
} else {
$query = $this->functions_model->validate_credentials_model();
if($query){
redirect('controlpanel');
} else {
$data_array = array('dashboard_msg' => "<p> Access denied. Please try again.</p>");
$this->session->set_flashdata($data_array);
redirect('login');
}
}
}
Here's my view:
Code:
<div id="login">
<form action="http://domain.com/login/validate_user" method="post" accept-charset="utf-8"><div>
<input type="hidden" name="csrf_test_name" value="f6df75341615931ce4cc651adf363aa4" />
</div>
<div id="log">
<p id='login-header'>Please login here</p>
<p class = 'pad-top-bottom'>
<label for="username">Username</label>
<input type="text" name="username" value="" class = 'round username-password' id = 'login-username' placeholder = 'Username' />
</p>
<p class = 'pad-top-bottom'>
<label for="password">Password</label>
<input type="password" name="password" value="" class = 'round username-password' id = 'login-password' placeholder = 'Password' />
</p>
<input type="submit" name="submit" value="Login" class = "blue icon-left round" id="login-button" /><a href="http://domain.coom#" id = 'anchor-forgot-password'>Forgot your password?</a></br></br></form>
</div>
Even I tried to display a text in my controller which looks like the code below, the problem still appears.
Code:
function validate_User(){
die('message appears');
// utilize validation helper
$this->form_validation->set_rules('username','Username','trim|required|max_length[5]');
$this->form_validation->set_rules('password','Password','trim|required|max_length[32]');
if($this->form_validation->run() == FALSE){
$data_array = array('dashboard_msg' => validation_errors());
$this->session->set_flashdata($data_array);
redirect('login');
} else {
$query = $this->functions_model->validate_credentials_model();
if($query){
redirect('controlpanel');
} else {
$data_array = array('dashboard_msg' => "<p> Access denied. Please try again.</p>");
$this->session->set_flashdata($data_array);
redirect('login');
}
}
}
I've search over the net regarding this problem but cannot find a solution for this. Is it CSRF in codeigniter causing this problem? Is there any problem with my code that causing the error?
Thanks so much!