2017-01-18 74 views
1

我有一個textarea,它是一個Ckeditor,但是我包含了允許我上傳圖像的ckfinder。 我需要將textarea內的所有數據發送到頁面以處理收到的數據。使用CKEditor和CKfinder並將內容保存到數據庫中

其實我無法發送textarea裏面的數據。

 <label>Corpo da Instrução de Trabalho</label> 
     <textarea name="editor1" id="editor1" rows="10" cols="80" placeholder="Escrever o conteúdo da IT aqui..."> 

     </textarea> 

     <script> 

     // Replace the <textarea id="editor1"> with a CKEditor 
     // instance, using default configuration. 

    // CKEDITOR.replace('editor1'); 

    var editor = CKEDITOR.replace('editor1'); 
    CKFinder.setupCKEditor(editor); 

    </script> 

當我試圖挽救其上接收到數據文件中的數據我做這樣的事:

$myText = $_POST['editor1']; 

但它是空的。

回答

0

您需要將其與表單一起提交。幷包括頭標記ckeditor.js文件:例如:

的index.php

<!DOCTYPE html> 
<html> 

<head> 
    <meta charset="utf-8"> 
    <meta name="robots" content="noindex, nofollow"> 
    <title>Classic editor replacing a textarea</title> 
    <script src="http://cdn.ckeditor.com/4.6.2/standard-all/ckeditor.js"></script> 
</head> 

<body> 
    <form action="savetextarea.php" method="post" > 

    <textarea cols="80" id="editor1" name="editor1" rows="10"> 
    </textarea> 

     <p> 
      <input type="submit" value="Submit"> 
     </p> 
    </form> 

    <script> 
     // CKEDITOR.replace('editor1'); 
    var editor = CKEDITOR.replace('editor1'); 
    CKFinder.setupCKEditor(editor); 
    </script> 
</body> 

</html> 

在同一個文件夾中創建savetextarea.php,不要忘了打印出來的內容:

<?php 

$my_text = $_POST['editor1']; 
print_r($my_text); 

當您刷新頁面從example :-)添加一些圖像,並添加一些文字,當您提交它,它會顯示在您的內容210

+0

我已經完成了你所說的。但是在我的savetextarea.php中,$ _PosT [''editor1']不存在。 –

+0

你的意思是它不會顯示在你的savetextarea.php中?嘗試我發佈在單獨的文件中的示例,它的工作原理。一行一行,並與您的代碼進行比較。檢查是否包含CK庫,並在savetextarea.php上需要顯示ckeditor。你是否在同一頁面提交你的表單?從沒有CKeditor的簡單事情開始。試試簡單的PHP表單,看看你是否有任何輸出。如果你有,那麼你可以移動到ckeditor實現。如果你有完整的例子,通過http://pastebin.com發送給我,並在這裏分享,我會解決它 – Blackcoat77

相關問題