2010-12-12 60 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的请求。