2010-12-12 118 views
0

似乎是瀏覽器問題,因爲在Firefox中它工作正常,但沒有在Chrome中。Mysql在插入數據後插入空行(在Chrome中)

爲什麼當我提交我的PHP表單插入數據到MySQL數據庫表中,然後檢查表。我看到我新創建的行中有數據,還有一行沒有任何內容?

我的控制器:

function Admin() { 
     parent::Controller(); 

     $this->dx_auth->check_uri_permissions(); 

     $this->load->model('alert_model'); 
     $data['rows'] = $this->alert_model->check($num_results=4); 
     $this->load->view('includes/header', $data); 
    } 

    function index() { 
     $this->load->view('admin/notifications'); 
     $this->load->view('includes/footer'); 
    } 

    function sendalert() { 
     $info = array(
      'msg_author' => $this->input->post('msg_author'), 
      'msg_date' => $this->input->post('msg_date'), 
      'msg_subject' => $this->input->post('msg_subject'), 
      'msg_content' => $this->input->post('msg_content') 
     ); 

     $this->send_notification->send($info); 
     $this->index(); 
    } 

我的模型:

function send($info) { 
     $this->db->insert('msg', $info); 
     return; 
    } 

筆者認爲:

<?php echo form_open('admin/sendalert'); ?> 

    <label for="msg_subject">Subject</label> 
    <input type="text" name="msg_subject" id="msg_subject" /> 

    <label for="msg_date">Date</label> 
    <input type="text" name="msg_date" id="msg_date" /> 

    <label for="msg_author">From</label> 
    <input type="text" name="msg_author" id="msg_author" /> 

    <label for="msg_content">Content</label> 
    <input type="text" name="msg_content" id="msg_content" /> 

    <input type="submit" value="submit" /> 

<?php echo form_close(); ?> 

謝謝

+0

它真的說'lable'而不是'label'嗎? – 2010-12-12 02:32:33

+0

lol nope,我的IDE自動改變這些出於某種原因,並忘記在粘貼之前將它們改回這裏 – Elgoog 2010-12-12 02:37:05

回答

2

嘗試改變

$this->index(); 

redirect('admin/index', 'refresh'); 
+0

工程就像一個魅力!謝謝。我猜測問題在於它沒有使用$ this-> index()正確重定向。在鉻。 – Elgoog 2010-12-13 01:52:17

0

代碼貼看起來不錯,但也許問題是:

$this->index(); 

你可以張貼指數()控制器的功能呢?

0

還要檢查你的日誌,如果有沒有第二個請求發送給服務器,由於某種原因被改寫爲index.php文件。最常見的是缺少圖像,難以找到的是favicon.ico的請求。