Forms Codeigniter表单输入Can';t Post表单数据

Forms Codeigniter表单输入Can';t Post表单数据,forms,codeigniter,Forms,Codeigniter,这看起来很傻,但我无法得到一个简单的表格来工作。这是我的密码: <section class="row-fluid"> <!-- search-by-text --> <div class="span8 offset1"> <!-- search by Name input field--> <form class="form-horizontal" role="form">

这看起来很傻,但我无法得到一个简单的表格来工作。这是我的密码:

<section class="row-fluid"> <!-- search-by-text -->       
     <div class="span8 offset1"> <!-- search by Name input field-->
            <form class="form-horizontal" role="form">
            <div class="form-group form-group-lg">
              <?php echo form_open('../main_controller/gsd_search'); ?>
              <label class="col-sm-2 control-label" for="formGroupInputLarge">Search by Name</label>
              <div class="col-sm-8">
                <input class="input input-lg input-block-level" type="text" id="search_text" placeholder="Enter name then click 'Search'">
              </div>
             <div class="col-sm-2"><!-- search button -->
                <?php echo form_submit('submit', 'Search by Name', "class='btn btn-large btn-success'"); ?>
                <?php echo form_close(); ?>
              </div> <!-- end search button -->         
                </div>
        </form>
    </div> <!-- end input field and button -->    

按姓名搜索

在调用CodeIgniter表单函数之前,您正在HTML中添加表单

<form class="form-horizontal" role="form">
...
</form>

...
删除HTML表单标记,因为您已经使用
form\u open()


请在此输入字段中输入名称,如

<input class="input input-lg input-block-level" type="text"  id="search_text" placeholder="Enter name then click 'Search'" name="search">



<pre>and remove html <form> tag because form_open() create form tag automatically</pre>

并删除html标记,因为form_open()会自动创建表单标记

尝试更正:

1) 使用其中一个,或者
或者Codeigniter的表单助手
表单打开()…表单关闭()
。因为您使用的是CI,所以请使用帮助器


2)每个输入标记中都应该有一个名称属性(无论是文本、隐藏、电子邮件、数字等字段)


3)在
表单_open()
中的操作错误。它应该遵循您的基本URL,而不是控制器的绝对URL


4)查看URL,我可以说您正在发出一个获取请求,但是
form\u open()
默认情况下会创建一个POST请求。因此,我不知道为什么会发生这种情况


修改代码:

查看-

class Main_controller extends CI_Controller
{
    public function __construct()
    {
       parent::__construct();
    }

    public function gsd_search()
    {
        // your POST data
    }
}

你需要添加到输入“名称”像你建议的修复工程。谢谢你的及时回复。是的,你是对的,这是一个愚蠢的重复。谢谢你的回复。
<section class="row-fluid"> <!-- search-by-text -->       
<div class="span8 offset1"> <!-- search by Name input field-->

   <div class="form-group form-group-lg">
    <?php 
       $attributes = array('class' => 'form-horizontal', 'role' => 'form');
       echo form_open('/main_controller/gsd_search', $attributes); 
    ?>
   <label class="col-sm-2 control-label" for="formGroupInputLarge">Search by Name</label>
          <div class="col-sm-8">
            <input class="input input-lg input-block-level" type="text" id="search_text" placeholder="Enter name then click 'Search'" name="search">
          </div>

         <div class="col-sm-2"><!-- search button -->
            <?php echo form_submit('submit', 'Search by Name', "class='btn btn-large btn-success'"); ?>
            <?php echo form_close(); ?>
          </div> <!-- end search button -->         
    </div>

</div> <!-- end input field and button --> 
class Main_controller extends CI_Controller
{
    public function __construct()
    {
       parent::__construct();
    }

    public function gsd_search()
    {
        // your POST data
    }
}