gpt4 book ai didi

php - 代码点火器没有将选择元素发送到数据库并且没有显示错误

转载 作者:行者123 更新时间:2023-11-29 19:37:22 25 4
gpt4 key购买 nike

我试图将 3 个不同的表中的 3 个 id 和 1 个 varchar 发送到一个名为“session”的表,它将保存 ids 和这个 varchar,我的问题是,每次我单击提交时,它不会向我的表输入任何内容表,并且没有显示错误..

查看

<link href='<?php echo site_url('assets/recursos/dashboard.css');?>' rel="stylesheet">
<div class="container">
<?php echo form_open('admin/inserirsessao'); ?>
<?php if (isset($message)) { ?>
<CENTER><h3 style="color:green;">Data inserted successfully</h3></CENTER><br>
<?php } ?>

<div class="col-xs-12">

<div class="form-group">
<label for="sel1">Filme</label>

<select name='filmes' class="form-control" id="filmes">
<?php
$id = $this->uri->segment(4);
$this->db->where('filme_id', $id);
$lista = $this->db->get('filme');
foreach($lista->result() as $row) {
?>
<option value="<?php echo $row->filme_id;?>"> <?php echo $row->Nome; ?></option>
<?php
}
?>
</select>
</div>

</div>



<h2 style="color:white; font-size:25px;">Adiciona um Filme<h2>
<div class="col-xs-12 ">
<div class="form-group">
<label for="sel1">Seleciona as Salas</label>

<select name='salas' class="form-control" id="salas">
<?php
$lista = $this->db->get('sala');
foreach($lista->result() as $row) {
?>
<option value="<?php echo $row->sala_id;?>" > <?php echo $row->description; ?></option>
<?php
}
?>
</select>
</div>

<div class="col-xs-12">
<div class="form-group">
<label for="sel1">Seleciona tipo de filme</label>

<select name="tipofilme" class="form-control" id="tipofilme">
<?php
$lista = $this->db->get('tipo_filme');
foreach($lista->result() as $row) {
?>
<option value="<?php echo $row->tipo_filme_id;?>"><?php echo $row->tipo_filme; ?></option>
<?php
}
?>
</select>
</div>
</div>

</div>

<div class="col-xs-12">






<p style="color:white" class="text-center">Insere Hora da Sessão</p>
<div class="separator">
<?php echo form_label('Hora:'); ?> <?php echo form_error('hora'); ?>
<?php echo form_input(array('id' => 'hora', 'name' => 'hora')); ?><br />

</div>


</div>
</ul>
</li>



<?php echo form_submit(array('id' => 'submit', 'value' => 'Submit')); ?> <br/>
<?php echo form_close(); ?><br/>

</div>

</div>

</div>

Controller

public function index()
{



$this->render('admin/inseresessao');



}

public function sessao()
{

$this->load->library('form_validation');

$this->form_validation->set_error_delimiters('<div class="error">', '</div>');

//Validating Name Field

$this->form_validation->set_rules('hora', 'Hora', 'required');

if ($this->form_validation->run() == FALSE) {
$this->render('admin/inserirsessao');
} else {
//Setting values for tabel columns


$dadossessao = array(
'hora' =>$this->input->post('hora'),
'sala_id'=>$this->input->post('salas'),
'tipo_filme_id'=>$this->input->post('tipofilme'),
'filme_id'=>$this->input->post('filmes')

);

//Transfering data to Model
$this->insert_model1->form_insert($dadossessao);

$dadosessao['message'] = 'Dados Foram Inseridos com Sucesso';
//Loading View
$this->render('admin/inserirsessao');
}
}
}

?>

型号

<?php
class insert_model1 extends CI_Model{
function __construct() {
parent::__construct();
}
function form_insert( $dadossessao){

$this->db->insert('session', $dadossessao);
return $dadossessao;

}
}
?>

我已经花了几个小时试图解决这个问题,但我不知道发生了什么,有人可以帮助我吗?

最佳答案

将表单操作更改为 <?php echo form_open('inserirsessao/sessao'); ?>

关于php - 代码点火器没有将选择元素发送到数据库并且没有显示错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41510149/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com