Welcome Guest, Not a member yet? Register   Sign In
access to subFolder from subFolder


I'm new to codeigniter and am quite excited to start my first application Big Grin

But as every rookie in this world, there are always "Brain hurters".

So.... As stated in this title:
I'm trying to access a view in a subfolder from a controller thats also set in a subfolder.

Controller: admin/login.php
View: admin/login.php

So in the controller I set
$this->load->view('admin/login', $data);

But I do get a 404 page.

When my controller is in the root of the controller folder it does work but not from a subfolder.

I also tried:
$this->load->view('../admin/login', $data);

But no use

Any help?

Kind regards
Muts (not real name :p)

Views belong in application/views, not in the controllers folder...


$this->load->view('admin/login', $data);

The location of the view, is fine... how you are loading it (using "admin/login") is fine... what maybe causing the problem is how you are accessing your controller.... which should be : yoursitehere.com/admin/login the 404 isn't because of the view... the 404 happens because it can't find the controller... According to the User Guide, all you should need to do is include the subfolder name when calling the controller...


Well these are the two files I have:


class Signup extends Controller {

    public function __construct() {

    public function index() {
    public function submit() {
        if ($this->_submit_validate() === FALSE) {
        // $this->load->view('submit_success');
    private function _submit_validate() {
        // validation rules
        $this->form_validation->set_rules('username', 'Username', 'required');
        $this->form_validation->set_rules('password', 'Password', 'required');
        $this->form_validation->set_message('authenticate','Invalid login. Please try again.');
        return $this->form_validation->run();

<!DOCTYPE html>
&lt;html lang="en"&gt;
    &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8"&gt;
    &lt;title&gt;Admin Panel&lt;/title&gt;
    &lt;link rel="stylesheet" href="&lt;?php echo base_url(); ?&gt;css/style.css"
        type="text/css" media="all"&gt;
    <div id="admin_login_form">
        &lt;?php echo validation_errors(); ?&gt;
        &lt;?php echo form_open('admin/login/submit'); ?&gt;
                <label for="username">Username: </label>
                &lt;?php echo form_input('username'); ?&gt;
                <label for="password">Password: </label>
                &lt;?php echo form_password('password'); ?&gt;
                &lt;?php echo form_submit('submit','Login'); ?&gt;
        &lt;?php echo form_close(); ?&gt;

So the placement should be good...

[eluser]Bart Mebane[/eluser]
Your controller filename has to match the class name.


I should stop writing several pages at once Big Grin

Thanks alot

Theme © iAndrew 2016 - Forum software by © MyBB