表单操作和锚点在codeigniter PHP中不起作用
我试图在表单操作和锚点在codeigniter PHP中不起作用,php,codeigniter,Php,Codeigniter,我试图在form\u open()中设置窗体的操作。在那里,我指定了登录文件(存在于控制器中,同时也是基本控制器文件)及其名为validate的函数。但是页面给出404对象未找到错误。我做错了什么?在anchor('login/signup','createaccount')中也会出现同样的错误。我希望我能解释我自己 /controller/login.php <?php class Login extends CI_Controller { function index() {
form\u open()
中设置窗体的操作。在那里,我指定了登录文件(存在于控制器中,同时也是基本控制器文件)及其名为validate
的函数。但是页面给出404对象未找到错误。我做错了什么?在anchor('login/signup','createaccount')中也会出现同样的错误代码>。我希望我能解释我自己
/controller/login.php
<?php
class Login extends CI_Controller
{
function index()
{
$this->load->helper('HTML');
$this->load->view('includes/header');
$this->load->view('login_form');
}
function signup()
{
$this->load->view('signup_form');
}
function validate()
{
}
}
?>
/查看/登录\u form.php
<div class="form_login">
<?php echo heading("Login",1); ?>
<?php
echo form_open('login/validate');
echo form_input('username','','placeholder ="Enter Username"');
echo form_password('pass','','placeholder ="Enter Password"');
echo form_submit('sub','Submit');
echo br();
echo anchor('login/signup','Create Account');
echo form_close();
?>
</div>
你也可以这样创建表单--
您没有加载表单帮助器。如果在类构造函数中加载模型、帮助程序等,则它们可用于类中的每个方法。更简单的方法是转到application/config/autoload.php并将它们放在那里。但这里有一个示例构造函数和一系列可能发生的事情,包括加载助手
class Login extends CI_Controller{
function __construct() {
// this is always required
parent::__construct();
// load some helpers
$this->load->helper('html');
$this->load->helper('url');
$this->load->helper('form');
// load some libraries
$this->load->library('form_validation');
$this->load->library('database');
$this->load->library('session');
// load models
$this->load->model( 'superusers' );
$this->load->model( 'dailyword' );
// create a variable with $this that can be used anywhere
$this->devmessage = '' ;
// call a method and return something that can be used anywhere
$this->wordoftheday = $this->dailyword->returnword() ;
}
因此,现在Login类中的任何方法,以及Login类调用的任何模型或视图文件都将具有上述所有帮助程序、库、模型等。在某些系统中,拼写帮助器名称大写也可能有效,但我建议始终将它们命名为小写 你在配置文件中设置了base_url了吗?我已经将我的登录页面设置为base controller了。我能知道你的skype id吗??通过skype,我可以很容易地解决。我还可以在codeigniter框架中提供更多帮助。目前我没有skype,对不起。我将安装它,但这需要一些时间。如果你想知道一些关于codeigniter的信息,我可以告诉你。为了解决我的问题
class Login extends CI_Controller{
function __construct() {
// this is always required
parent::__construct();
// load some helpers
$this->load->helper('html');
$this->load->helper('url');
$this->load->helper('form');
// load some libraries
$this->load->library('form_validation');
$this->load->library('database');
$this->load->library('session');
// load models
$this->load->model( 'superusers' );
$this->load->model( 'dailyword' );
// create a variable with $this that can be used anywhere
$this->devmessage = '' ;
// call a method and return something that can be used anywhere
$this->wordoftheday = $this->dailyword->returnword() ;
}