Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

hi everybody m new here with codeignator!! i have a controller as in the following:

<?php if(!defined ('BASEPATH')) exit('not found basepath');

class **myController** extends CI_Controller{

    function __constructor(){
        parent::__constructor();
    }
    public function index(){
        $this->load->view('myview');
    }
    **public function myFn()**{
    echo "my controller is called"; 
    }


    }


?>

and view is in the following:

<form action="<?php echo base_url();?>myController/myFn" method="post" name="myform">
<input type="submit" name="submit" value="submit"/>
</form>

the problem is that when i run the view by going to localhost after clicking at the submit m intimating by the following error!!!

**The requested URL /CodeIgniter/myController/myFn was not found on this server.**

but when i put **http://localhost/CodeIgniter/index.php/myController/myFn** i got the correct output of the view anybody is here who can help me in this regard thnx in advance....

share|improve this question

3 Answers

I think you don't have these lines in your .htaccess file

RewriteCond $1 !^(index\.php|indexcp\.php?|resources|robots\.txt)
RewriteRule ^([A-Za-z0-9_/-]+)$ index.php?/welcome/$1 

Edit

Open notepad and paste this code and save as ".htaccess" no file name at root folder

#php_value upload_max_filesize 100M
#php_value post_max_size 100M
RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond $1 !^(index\.php|indexcp\.php?|resources|robots\.txt)
RewriteRule ^([A-Za-z0-9_/-]+)$ index.php?/welcome/$1 

RewriteRule ^(CSI) index.php?/CSI
AddType text/x-component .htc
share|improve this answer
can u send me the whole procedure – AliMohsin Jul 27 '12 at 10:16
@AliMohsin: check the edit – MR Srinivas Jul 27 '12 at 10:42
the files doesn't save with this name – AliMohsin Jul 28 '12 at 4:19

when you run the view

<form action="<?php echo base_url();?>myController/myFn" method="post" name="myform">
<input type="submit" name="submit" value="submit"/>
</form>

use inspect element to see if the action in the form tag is same as

**http://localhost/CodeIgniter/index.php/myController/myFn**
share|improve this answer
the following link is there localhost/CodeIgniter/blog/myfn – AliMohsin Jul 27 '12 at 10:20
but u said it works on localhost/CodeIgniter/index.php/myController/myFn and in form it is localhost/CodeIgniter/blog/myfn see and tell me if both looks same to u – danish hashmi Jul 27 '12 at 12:31
in case of putting index.php it shows the result but in case of link without index.php it doesn't show the out put..... – AliMohsin Jul 28 '12 at 4:18
if you dont need to use index.php you will have to make changes in routes.php as well as htaccess and you are good to go – danish hashmi Jul 30 '12 at 5:00
from index.php and from routes.php???how can ??? – AliMohsin Jul 30 '12 at 9:03
show 1 more comment

In your controller just delete ' ** '.

load->view('myview'); } public function myFn(){ echo "my controller is called"; } } ?>

And In your view try:

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.