0
votes

i have a logout link which is directed to a function in the controller. But i get an error when i run the program.please help

Home.php

<div align='left'>
<a href ='<?php echo base_url()."main/logout" ?>'>Log Out</a>
</div>

Main controller

public function logout()
{
$this->session->sess_destroy();
redirect('main/login');

}

I get this error when i click log out

Object not found!

The requested URL was not found on this server. The link on the referring page seems to be wrong or outdated. Please inform the author of that page about the error.

If you think this is a server error, please contact the webmaster.

Error 404

localhost Tue Oct 28 15:46:16 2014 Apache/2.2.14 (Unix) DAV/2 mod_ssl/2.2.14 OpenSSL/0.9.8l PHP/5.3.1 mod_perl/2.0.4 Perl/v5.10.1

1
You gave us almost no information at all. If you get 404 you probably dont have the file in the place that you are trying to get it from.Rafał Swacha
Where does the link take you? (URL)? Are you sure the logout() method is in the correct controller (i.e. Main)?ggdx
i have given a function named log out in the controller called main. in the function ,it redirects me back to my login page. sorry i am little new to ci.Ravi
Try using site_url() instead of base_url()Craig
can you shows you base_urlDexter

1 Answers

0
votes

missing index.php. try this

<a href="<?php echo base_url('index.php/main/logout'); ?> ">Logout</a>