2017-03-03 118 views
-1

在PHP中,如何回顯textarea的值?我下面的代碼不起作用。如何從文本區回顯數據

<form name="code_editor" action="index.php" method="post"> 
    <textarea name="code" rows="8" cols="80"></textarea> 
    <input type="submit" value="Upload"> 
</form> 

我這個名爲「的index.php」和上面的代碼單獨的文件中是index.html,

<?php 
    echo $_POST['code_editor']; 
?> 
+0

該字段的名稱屬性意味着被稱爲獲取有關該字段的數據。順便說一句,你不需要命名你的表格。我的建議並沒有在同一個網站上列出index.html和index.php。 –

回答

0

你需要抓住你想現場實際回聲。

<?php 
    echo htmlspecialchars($_POST["code"]); 
?> 

編輯:我爲安全性添加了「htmlspecialchars」。沒有技術上的要求,但確保你這樣做。

相關問題