doufei0933 2010-12-12 02:29
浏览 31
已采纳

插入行数据后,Mysql插入空行(在Chrome中)

Seems to be a browser issue, as in firefox it is working fine but not in chrome.

Why is it that when I submit my php form to insert data into a mysql db table, then check the table. I see my newly created row with the data in it and also an extra row with nothing in it?

My controller:

    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();
    }

My Model:

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

My View:

<?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(); ?>

Thanks

  • 写回答

3条回答 默认 最新

  • duanpo1498 2010-12-12 08:36
    关注

    Try change

    $this->index();
    

    to

    redirect('admin/index', 'refresh'); 
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目
  • ¥20 mysql架构,按照姓名分表
  • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分
  • ¥15 delphi webbrowser组件网页下拉菜单自动选择问题
  • ¥15 linux驱动,linux应用,多线程