我正在尝试将数据插入数据库但它不起作用。它只捕获我通过表单输入的数据并显示在URL栏上。
在我的视图 input_data.php 下面,它位于: C:\ wamp \ www \ CodeIgniter \ application \ views \ form \ input_data.php 。
<md-autocomplete md-selected-item="diagnostico" md-search-text="searchText.DiagnosticName" md-items="diagnostico in diagnosticos | filter:searchText" md-item-text="diagnostico.DiagnosticName" placeholder="Search" md-min-length="1" md-clear-button="true">
<md-item-template>
<span>{{diagnostico.DiagnosticName}}</span>
<span>{{diagnostico.DiagnosticDescription}}</span>
</md-item-template>
以下是位于 application \ model \ login.php 中的模型 login.php ,数据库中的表是 come_list 。
<form>
<?php echo validation_errors(); ?>
<?php echo form_open('form'); ?>
<fieldset>
<div class="form-group">
<div class="row colbox">
<div class="col-lg-3 col-sm-3">
<label for="lettername" class="control-label pull-right">ឈ្មោះលិខិត/ខ្លឹមសារ</label>
</div>
<div class="col-lg-9 col-sm-9">
<input id="letter_name" size="50" name="letter_name" placeholder="ខ្លឹមសារលិខិត" type="text" class="form-control" value="<?php echo set_value('letter_name'); ?>" />
<span class="text-danger"><?php echo form_error('letter_name'); ?></span>
</div>
</div>
</div>
<div class="form-group">
<div class="row colbox">
<div class="col-lg-3 col-sm-3">
<label for="letternumber" class="control-label pull-right">លេខលិខិត</label>
</div>
<div class="col-lg-9 col-sm-9">
<input id="letter_number" size="50" name="letter_number" placeholder="លេខលិខិត" type="text" class="form-control" value="<?php echo set_value('letter_number'); ?>" />
<span class="text-danger"><?php echo form_error('letter_name'); ?></span>
</div>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-3 col-lg-9 col-sm-9 text-left">
<input id="btn_add" name="btn_add" type="submit" class="btn btn-primary" value="បញ្ចូល" />
<input id="btn_cancel" name="btn_cancel" type="reset" class="btn btn-danger" value="លុបចេញ" />
</div>
</div>
</fieldset>
</form>'
下面的是控制器 Main.php :
<?php
if (!defined('BASEPATH')) exit('No direct script access allowed');
Class Login extends CI_Model {
function add_letter($data){
$this->db->insert('come_list', $data);
echo "user Added";
}
}
?>
答案 0 :(得分:1)
我认为问题在于你的形式行动。使用此表格
<form role="form" method="post" action="<?php echo base_url();?>main/insert_come">
结束表格使用后
</form>
答案 1 :(得分:0)
发布数据也将在模型中提供,无需从控制器发送
$this->Name = $_POST('letter_name');
$this->Letter_Number = $_POST('letter_number')
$this->db->insert('come_list', $this);
答案 2 :(得分:0)
var extensionType = facts.dimension(function(d) {
return d.extension; });
var extensionTypeGroup=extensionType.group();
Controller main.php
{"key":"class","value":424},
{"key":"js","value":176},
{"key":"properties","value":26},
{"key":"jar","value":10},
{"key":"css","value":8},
{"key":"txt","value":6},
{"key":"war","value":4},
{"key":"png","value":4},
{"key":"handlebars","value":4},
{"key":"jar_local","value":2},
{"key":"aar","value":2}
Codeigniter Model login.php
<?php if(isset($msg) && !empty($msg)) echo $msg; ?>
<form action="<?php echo base_url('main/insert_come'); ?>" method="POST">
<?php echo validation_errors(); ?>
<fieldset>
<div class="form-group">
<div class="row colbox">
<div class="col-lg-3 col-sm-3">
<label for="lettername" class="control-label pull-right">ឈ្មោះលិខិត/ខ្លឹមសារ</label>
</div>
<div class="col-lg-9 col-sm-9">
<input id="letter_name" size="50" name="letter_name" placeholder="ខ្លឹមសារលិខិត" type="text" class="form-control" value="<?php echo set_value('letter_name'); ?>" />
<span class="text-danger"><?php echo form_error('letter_name'); ?></span>
</div>
</div>
</div>
<div class="form-group">
<div class="row colbox">
<div class="col-lg-3 col-sm-3">
<label for="letternumber" class="control-label pull-right">លេខលិខិត</label>
</div>
<div class="col-lg-9 col-sm-9">
<input id="letter_number" size="50" name="letter_number" placeholder="លេខលិខិត" type="text" class="form-control" value="<?php echo set_value('letter_number'); ?>" />
<span class="text-danger"><?php echo form_error('letter_number'); ?></span>
</div>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-3 col-lg-9 col-sm-9 text-left">
<input id="btn_add" name="btn_add" type="submit" class="btn btn-primary" value="បញ្ចូល" />
<input id="btn_cancel" name="btn_cancel" type="reset" class="btn btn-danger" value="លុបចេញ" />
</div>
</div>
</fieldset>
</form>