Php 插入件在编码点火器中工作不正常

Php 插入件在编码点火器中工作不正常,php,codeigniter,Php,Codeigniter,我正在尝试将数据插入数据库,我的代码确实添加了一个新行,但是所有的值都是空的。我不知道是什么引起的。该视图位于html模式中。这是我的密码:谢谢你的帮助 控制器: public function addItem(){ $save = array( 'inventoryID' => $this->input->post('rfid'), 'masterCode' => $this->input->post('masterC

我正在尝试将数据插入数据库,我的代码确实添加了一个新行,但是所有的值都是空的。我不知道是什么引起的。该视图位于html模式中。这是我的密码:谢谢你的帮助

控制器:

public function addItem(){
    $save = array(
        'inventoryID' => $this->input->post('rfid'),
        'masterCode' => $this->input->post('masterCode'),
        'itemName' => $this->input->post('itemName'),
        'colorName' => $this->input->post('colorName'),
        'location' => $this->input->post('location'),
        'itemCategory' => $this->input->post('itemCategory'),
        'materialDescription' => $this->input->post('materialDescription'),
        'supplier' => $this->input->post('supplier'),
        'itemDescription' => $this->input->post('itemDescription'),
        'comments' => $this->input->post('comments'),
        'itemCode' => $this->input->post('itemCode'),
        'colorCode' => $this->input->post('colorCode')
    );
    $this->searchModel->form_insert($save);

    //load the header
    $this->load->view('base.php',$save);
    //load the page
    redirect('Search');
    //load the footer
    $this->load->view('footer.php',$save);
}
型号:

函数表单插入($data){

视图:



问题是您实际上没有“提交”表单数据。您的按钮链接到正确的控制器/方法,但在使用链接时不会向控制器发送任何数据,即
hi,首先您不需要添加标记
public function addItem(){print\u r($this->input->post());die();然后检查表中的列名是什么?您的SQL表列可能具有错误的数据类型和默认值。显示了您的架构
    // Inserting in Table(inventory) of Database(library)
    $this->load->database();
    $this->db->insert('inventory', $data);
    $inventoryID = $this->db->insert_id();
}
<div id="addItem" class="modal fade">
  <div class="modal-dialog">
    <div class="modal-content">
      <form method ="post" action= "<?php echo site_url("Search/addItem"); ?>">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
          <h4 class="modal-title">Add an Item</h4>
        </div>
        <div class="modal-body">
          <form role="form">
            <table>
              <tr>
                <td><input type="text" name="rfid" placeholder="RFID" required/></td>
                <td><input type="text" name="itemCode" placeholder="Item Code" required/></td>
                <td><input type="text" name="masterCode" placeholder="Master Code" /></td>
              </tr>
              <tr>
                <td><input type="text" name="itemName" placeholder="Item Name" required/></td>
                <td><input type="text" name="colorCode" placeholder="Color Code" /></td>
                <td><input type="text" name="colorName" placeholder="Color Name" /></td>
              </tr>
              <tr>
                <td><input type="text" name="location" placeholder="Location" required/></td>
                <td><input type="text" name="makelocation" placeholder="Location Made" required/></td>
                <td><input type="text" name="itemCategory" placeholder="Item Category" /></td>
              </tr>
              <tr>
                <td><input type="text" name="materialDescription" placeholder="Material Description" /></td>
                <td><input type="text" name="supplier" placeholder="Supplier/Vendor" required/></td>
                <td><input type="text" name="checkoutAllowed" placeholder="Checkout Allowed" /></td>
              </tr>
            </table>
            <div class="row personal-info">
              <div class="col-sm-4">
                <div class="form-group">
                  <textarea name="itemDescription" placeholder="Insert information regarding the weather this item is suitable for and where it is used"></textarea>
                  <textarea name="Comments" placeholder="Additional Coments on the Item"></textarea>
                </div>
              </div>
            </div>
          </form>
        </div>
        <div class="modal-footer" style="text-align:center;">
          <a href="<?php echo site_url("Search/addItem") ?>"><input class="btn btn-primary" name="addItem" value="Add Item"></a>
        </div>
      </form>
    </div>
  </div>
</div>
<div class="modal-footer" style="text-align:center;">
  <input type="submit" class="btn btn-primary" name="addItem" value="Add Item">
</div>
<form method ="post" action="<?php echo site_url("Search/addItem"); ?>">
<form role="form">
<form method="post" action="<?php echo site_url("Search/addItem"); ?>" role="form">
<div id="addItem" class="modal fade">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
        <h4 class="modal-title">Add an Item</h4>
      </div>
      <div class="modal-body">
        <form method ="post" action= "<?php echo site_url("Search/addItem"); ?>" role="form">
          <table>
            <tr>
              <td><input type="text" name="rfid" placeholder="RFID" required/></td>
              <td><input type="text" name="itemCode" placeholder="Item Code" required/></td>
              <td><input type="text" name="masterCode" placeholder="Master Code" /></td>
            </tr>
            <tr>
              <td><input type="text" name="itemName" placeholder="Item Name" required/></td>
              <td><input type="text" name="colorCode" placeholder="Color Code" /></td>
              <td><input type="text" name="colorName" placeholder="Color Name" /></td>
            </tr>
            <tr>
              <td><input type="text" name="location" placeholder="Location" required/></td>
              <td><input type="text" name="makelocation" placeholder="Location Made" required/></td>
              <td><input type="text" name="itemCategory" placeholder="Item Category" /></td>
            </tr>
            <tr>
              <td><input type="text" name="materialDescription" placeholder="Material Description" /></td>
              <td><input type="text" name="supplier" placeholder="Supplier/Vendor" required/></td>
              <td><input type="text" name="checkoutAllowed" placeholder="Checkout Allowed" /></td>
            </tr>
          </table>
          <div class="row personal-info">
            <div class="col-sm-4">
              <div class="form-group">
                <textarea name="itemDescription" placeholder="Insert information regarding the weather this item is suitable for and where it is used"></textarea>
                <textarea name="Comments" placeholder="Additional Coments on the Item"></textarea>
              </div>
            </div>
          </div>
          <div class="modal-footer" style="text-align:center;">
            <input type="submit" class="btn btn-primary" name="addItem" value="Add Item">
          </div>
        </form>
      </div>
    </div>
  </div>
</div>