2016-01-22 51 views
2

。對於數據庫我使用mysql。但是當我點擊提交按鈕提交表單時,數據庫正在更新,但是頁面沒有重定向到不同的位置。在使用CK編輯器進行更新後,頁面不會重定向

<?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> 

當我點擊保存它應該更新表1和重定向到的index.php。但我的程序正在更新表,但不重定向到index.php ...但是當我不使用ck編輯器,它的工作完全正常....如何使它與ck編輯器一起工作?

+0

你在控制檯中得到了什麼錯誤? –

+0

沒有錯誤什麼那麼...查詢運行正常...表正在更新以及...但查詢執行後,該頁面不重定向到index.php ....它停留在相同的頁面.... –

回答

0

更改textarea ID,按您的字段名稱爲:

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

它仍然無法正常工作.. :( –

0

添加模具()或exit()

由於模具()或exit()後您的

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

阻止它導致意想不到的行爲。

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

你試過...? –

0

如何呼應<script>location.href=/page.php</script>而不是PHP的頭? 只有在沒有其他內容輸出時才允許重定向,而此選項只要寫入文檔就會重定向,無論如何。