簡體   English   中英

使用ck編輯器更新后頁面未重定向

[英]Page is not redirecting after update with ck editor

我正在使用CK編輯器。 對於使用MySQL的數據庫Im。 但是,當我單擊“提交”按鈕提交表單時,數據庫正在更新,但是頁面未重定向到其他位置。

  <?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編輯器一起工作?

根據您的字段名稱將textarea id更改為:

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

添加die()或exit()

由於die()或exit()在您之后

 header('Location:http://something') 

防止導致意外行為。

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

如何回顯<script>location.href=/page.php</script>而不是php標頭? 僅當沒有其他內容輸出時,才允許重定向,而無論此選項是什么,只要將其寫入文檔,便會進行重定向。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM