使用ck编辑器更新后,页面不会重定向

时间:2016-01-22 06:23:46

标签: php jquery mysql redirect

我正在使用CK编辑器。对于数据库我使用mysql。但是,当我单击提交按钮提交表单时,数据库正在更新,但页面不会重定向到其他位置。

  <?php 



  $sql="select * from automation_full";
  $query=mysql_query($sql_get);
  $row=mysql_fetch_object($query_get);
  $old_content=$row->column1;

  if(isset($_POST['save']))
  {
    $new_content=$_POST['content'];

    $sql="update table1 set content='$new_content' where key_id=1";
    $query=mysql_query($sql);

    if($query)
        {
            header("Location:index.php");
        }

  }


  ?>

    <div class="custom-container-right-form">



        <form action="#" method="post">


            <textarea id="text" name="content"></textarea>
             <script>
                CKEDITOR.replace( 'content' );
            </script>

            <input type="submit" id="submit-button" name="save" value="Update">


        </form>

    </div> 

当我点击保存时,它应该更新table1并重定向到index.php。但是我的程序正在更新表但没有重定向到index.php ...但是当我不使用ck编辑器时它完全正常....如何使它与ck编辑器一起工作?

3 个答案:

答案 0 :(得分:0)

根据您的字段名称更改textarea ID:

<textarea id="content" name="content"></textarea>
<script>
    CKEDITOR.replace( 'content' );
</script>

答案 1 :(得分:0)

添加 die()或退出()

  

之后 die()或exit()
header('Location:http://something')
     

防止它导致意外行为。

if($query)
        {
            header("Location:index.php");
            die();
        }

答案 2 :(得分:0)

如何回显<script>location.href=/page.php</script>而不是php标头? 这只允许在没有输出其他内容时进行重定向,而此选项一旦被写入文档就会重定向,无论如何。

相关问题