[英]Something goes wrong with my controller I may have mistake somewhere of it
這是我的控制器
function new_post(){
if($_POST){
$data=array(
'title'=>$_POST['title'],
'post'=>$_POST['post'],
'active'=>1);
$this->post->insert_post($data);
redirect('post/');
}
else {
$this->load->view('new_post');
}
}
這個控制器好,這不起作用, 模型這是它僅插入表格的模型。
function insert_post($data){
$this->db->insert('posts',$data);
return $this->db->insert_id();
}
如果我將其更改為
$data=array(
'title'=>$_POST['title'],
'post'=>$_POST['post'],
'active'=>1);
$this->post->insert_post($data);
然后就可以了
我沒有在第一個控制器上犯任何錯誤,因為它沒有插入...。
問候
嘗試更換
redirect('post/');
與
header('Location:your_url');
redirect會立即重定向您,而不知道前面的語句不是執行header而是執行header。 會做到的
我認為是造成問題的原因
將if($_POST){
更改為此
if($_POST['title'] && $_POST['post']){
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.