假设我有这样一个表单:
<form action="page.php" method="post">
Section1: <input name="section1" type="text"></br>
Section2: <input name="section2" type="text"></br>
Text:</br>
<textarea name="post_text" cols="100" rows="20"></textarea>
<input name="submit" type="submit" value="Submit">
</form>
通常,如果我希望保存插入到表单字段中的内容,我会使用以下语句:
Section1: <input name="section1" type="text" vale="value="<?php echo $_POST['section1']; ?>""></br>
这样如果我在提交时出错(没有发布错误控制代码),插入的值将被保留,并且不需要重新插入它们。
但是在 textarea 标签中使用它不会产生预期的结果。
关于如何做的任何想法?
提前致谢!
最佳答案
不要忘记 htmlspecialchars() .这应该有所帮助:https://developer.mozilla.org/en/HTML/Element/textarea
<textarea name="post_text" cols="100" rows="20"><?php echo htmlspecialchars($_POST['post_text']);?></textarea>
关于php - 如何在错误提交后将文本插入到 html <textarea> 中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7632660/