如何从codeignator中的视图调用控制器函数

如何从codeignator中的视图调用控制器函数

本文介绍了如何从codeignator中的视图调用控制器函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

hi每个人都在这里与codeignator!
i的控制器如下:

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>

问题是,当我运行视图通过转到localhost单击提交m以下错误!!!

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.**

但是当我放置 ** http:// localhost / CodeIgniter / index .php / myController / myFn ** 我得到正确的视图输出
任何人都在这里谁可以帮助我在这方面thnx提前....

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

推荐答案

查看侧

 <form method="post" action="<?php echo base_url();?>index.php?controlerfile/test" class="form">
Message: <input type="text" name="message">
<input type="submit" value="submit">

<div>
You have entered:
<?php echo $message; ?>
</div>

controllerfile

controllerfile

function test()
{

    $data['message']= $this->input->post('message');
            //$this->output->append_output($message);

    $this->load->view('backend/test',$data);


}

希望这会帮助你..

这篇关于如何从codeignator中的视图调用控制器函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-03 01:11