Php 表单操作url在codeigniter中不起作用
我试图在表单操作中使用url,而不在codeigniter中使用表单助手,但它不起作用Php 表单操作url在codeigniter中不起作用,php,codeigniter,base-url,Php,Codeigniter,Base Url,我试图在表单操作中使用url,而不在codeigniter中使用表单助手,但它不起作用 <form method="post" action="<?php echo base_url().'test'; ?>"> <form method="post" action="/main_controller/test"> 我得到的错误 应该是 <form method="post" action="<?php echo base_url()?&g
<form method="post" action="<?php echo base_url().'test'; ?>">
<form method="post" action="/main_controller/test">
我得到的错误
应该是
<form method="post" action="<?php echo base_url()?>index.php/main_controller/test">
index.php/main\u controller/test
^ ^ ^ ^
基本URL索引控制器名称方法名称
查看。
要使用基本url()
,必须首先加载url帮助程序。这可以在application/config/autoload.php
(第67行附近)中完成:
或者,在控制器中手动:
$this->load->helper('url');
然后改变
<form method="post" action="<?php echo base_url().'test'; ?>">
默认情况下,index.php文件将包含在您的url中:您可以使用.htaccess file
从操作url中删除index.php。请阅读,否则请在路由文件中设置短方法名称,否则很晚才接受,谢谢您的帮助
<?php echo base_url()?>index.php/main_controller/test
^ ^ ^ ^
base URL index Controller Name Method name
<form method="post" action="<?php echo base_url().'/main_controller/test/'; ?>">
$autoload['helper'] = array('url');
$this->load->helper('url');
<form method="post" action="<?php echo base_url().'test'; ?>">
<form method="post" action="<?php echo base_url()?>index.php/main_controller/test">
$config['base_url'] = 'http://example.com/';