【发布时间】:2012-04-06 16:13:18
【问题描述】:
我是 Codeigniter 编程的新手。我通过简单地编辑我的默认控制器欢迎启动 CI。我在控制器中添加了一个函数,该函数在单击提交按钮时被调用。我没有在默认框架或配置文件中进行任何修改。但是在单击提交按钮时,应用程序会返回 404 响应。 未找到 在此服务器上找不到请求的 URL /login/welcome/main。 Apache/2.2.14 (Ubuntu) 服务器在 localhost 端口 80
主要功能是我在欢迎控制器中写的。谁能告诉我出了什么问题。我的 Codeigniter 版本是 2.1.0。 我重新安装了 Apache 和 PHP。但是没用还是一样。来自控制器的代码和下面的欢迎页面。
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
error_reporting(E_ALL);
class Welcome extends CI_Controller {
/**
* Index Page for this controller.
*
* Maps to the following URL
* http://example.com/index.php/welcome
* - or -
* http://example.com/index.php/welcome/index
* - or -
* Since this controller is set as the default controller in
* config/routes.php, it's displayed at http://example.com/
*
* So any other public methods not prefixed with an underscore will
* map to /index.php/welcome/<method_name>
* @see http://codeigniter.com/user_guide/general/urls.html
*/
public function index()
{
$this->load->view('login_page');
//$this->load->view('phpinfo');
}
public function main()
{
$this->load->view('phpinfo');
}
欢迎页面是
<div id="container">
<h1>Ignitor</h1>
<div id="body">
<code>Please Login to continue. </code>
<div id="login_form">
<?php echo form_open(base_url().'welcome/main');?>
<ul>
<li>
<label>Username </label>
<?php echo form_input(array('id' => 'username', 'name' => 'Username'));?>
</li>
<li>
<label>Password </label>
<?php echo form_password(array('id' => 'password', 'name' => 'Password'));?>
</li>
<li> <?php echo form_submit(array('id'=>'submit'),'Let me in' )?></li>
</ul>
<?php echo form_close();?>
*/
【问题讨论】:
-
你必须像这样放置表单动作。 login/welcome/main/ 你必须在你的配置文件中设置 base_url
-
对不起。我没有完全理解你。我已经正确设置了 base_url() 函数。把它放在这里是什么意思..?感谢回复
标签: php model-view-controller function codeigniter controllers