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

编程入门 行业动态 更新时间:2024-10-09 11:20:09
本文介绍了如何从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 **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....

推荐答案

查看侧

<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中的视图调用控制器函数?

本文发布于:2023-11-17 11:02:39,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1609805.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:视图   控制器   函数   codeignator

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!