Welcome Guest, Not a member yet? Register   Sign In
one page will load but the other will not? same controller
#1

[eluser]Firenter[/eluser]
Hi forums!

I'm getting this weird problem that makes one of my pages give a 404 error when trying to load it.
I'm not sure where i'm going wrong with this so here's the code for the entire controller.

Code:
class index extends CI_Controller {

    public function __construct() {
        parent::__construct();
        $this->load->helper('form');
        
        $this->load->library('session');
    }

    public function index() {
        $data['title'] = 'Studypointer';

        $partials = array('header' => 'main_header', 'content' => 'home', 'sidebar'=>'side', 'footer' => 'main_footer');
        $this->template->load('main_master', $partials, $data);
    }
    
    public function login(){
        
        if($this->session->userdata('login')==0){
            $data['title'] = "Studypointer login";
            $partials = array('header' => 'main_header', 'content' => 'login', 'sidebar'=>'side', 'footer' => 'main_footer');
            $this->template->load('main_master', $partials, $data);
        }
        else{
            if($this->session->userdata('login')==1){
                redirect('docent/index');
            }else{
                redirect('admin/index');
            }
        }
    }
}

The function that's not working is the login.
I've tried just copying the index function and changing the 'content' variable from home to login but that doesn't work either.
If you have any suggestions please let me know...
#2

[eluser]PhilTem[/eluser]
Do you go to

your.domain.com/index.php/index/login

to see the desired output, or do you call

your.domain.com/index.php/login?

Watch the /index in the first link. And don't care about the index.php, it won't make a difference and it's safer, to call your webpage with index.php so we can exclude any possible errors from your .htaccess Wink
#3

[eluser]Firenter[/eluser]
Oh wow thanks for that, I was calling the second one.
Silly rookie mistakes...

Thanks for the answer!
#4

[eluser]Firenter[/eluser]
Hey, another question because I'm getting 404 errors again <_<

I'm using the form helper and when I submit this form I get a 404, the function logmein exists in the controller, I've checked the spelling and all and it should just return me to the homepage after it's finished but it just gives me the error.

Code:
$attributes = array('name' => 'adminloginform');
    echo form_open('/admin/logmein', $attributes);

    echo form_label('Username:', 'naam');
    $textboxdata = array('name' => 'naam', 'id' => 'naam');
    echo form_input($textboxdata);

    echo "<br/> <br/>";

    echo form_label('Wachtwoord', 'pass');
    $passworddata = array('name' => 'pass', 'id' => 'pass');
    echo form_password($passworddata);

    echo "<br/> <br/>";

    echo form_submit('adminsubmit', 'Log in');

    echo form_close();
#5

[eluser]InsiteFX[/eluser]
Take the first forward slash off of your form_open
#6

[eluser]Firenter[/eluser]
I tried it, still the same result...
#7

[eluser]Aken[/eluser]
1) Find the valid URL that it should point to.
2) Compare that with the URL that the form is sending you to, and see what's wrong.
#8

[eluser]Firenter[/eluser]
I think the valid url should be: my.domain.here/project/index.php/admin/logmein
But when I go there without the form it doesn't work either...
Unless it should be something I'm completely overlooking.
#9

[eluser]Firenter[/eluser]
I fixed it guys!
When I copied the code from the old controller to make the new one I forgot to change the name of the class, thus resulting in non-existant controllers!

Silly me!!!!
#10

[eluser]InsiteFX[/eluser]
Did you load the url_helper?




Theme © iAndrew 2016 - Forum software by © MyBB