Hi, I just started studying codeigniter and I am now creating a login form. I got the code from external sources and now I’m getting an error with the code. Here’s the error:
The page you requested was not found.
technically, the page I am requesting cannot be found. here’s the snippet of my VIEW:
<div class="modal-body">
<?php echo validation_errors(); ?>
<?php echo form_open('verifylogin'); ?>
<form method="POST">
<div class="form-group">
<label for="Username">Username</label>
<input type="text" class="form-control" id="exampleInputEmail1" placeholder="Username" name="user">
</div>
<div class="form-group">
<label for="Password">Password</label>
<input type="password" class="form-control" id="exampleInputPassword1" placeholder="Password" name="pass">
</div>
<div class="checkbox">
<label>
<input type="checkbox"> Remember Me
</label>
</div>
<button type="submit" class="btn btn-default" value="Login">Submit</button>
</form>
</div>
what causing the error is this `<?php echo form_open('verifylogin'); ?>
`When I patients login button at the sidebar section a modal form will come out. When you click the submit it redirects to verifylogin controller.
This is the verifylogin .php code located in my controller:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class VerifyLogin extends CI_Controller {
function __construct()
{
parent::__construct();
$this->load->model(‘user’,‘’,TRUE);
}
function index( $page = ‘home’ )
{
if ( ! file_exists(APPPATH.‘/views/pages/’.$page.‘.php’)){
show_404();
}
//This method will have the credentials validation
$this->load->library(‘form_validation’);
$this->form_validation->set_rules(‘user’, ‘Username’, ‘trim|required|xss_clean’);
$this->form_validation->set_rules(‘pass’, ‘Password’, ‘trim|required|xss_clean|callback_check_database’);
if($this->form_validation->run() == FALSE)
{
//Field validation failed. User redirected to login page
$this->load->view(‘pages/’.$page);
}
else
{
//Go to private area
redirect(‘patient’, ‘refresh’);
}
}
function check_database($password)
{
//Field validation succeeded. Validate against database
$username = $this->input->post(‘username’);
//query the database
$result = $this->user->login($username, $password);
if($result)
{
$sess_array = array();
foreach($result as $row)
{
$sess_array = array(
‘id’ => $row->id,
‘username’ => $row->username
);
$this->session->set_userdata(‘logged_in’, $sess_array);
}
return TRUE;
}
else
{
$this->form_validation->set_message(‘check_database’, ‘Invalid username or password’);
return false;
}
}
}
What I want to achieve is when successful login, my hidden page would appear on the menu. Here’s the site: http://ospar.netau.net/
Thank you