php - 无法以 html 形式保存 textarea 的数据

标签 php html forms echo

我使用 php 从 html5 表单获取数据,我试图保留字段的数据而不被清除。

它适用于输入,但无法用于文本区域(描述字段)。

您可以在下面看到我在输入中添加了一个 php echo 作为值,但它不适用于 textarea。 我怎样才能使它也适用于 textarea?

HTML 格式:

<form method='post' action='entry.php' enctype="multipart/form-data">
<label for="username"> Username: </label>
<input type="text" name="username" id="username" value="<?php echo $username; ?>" /></br>
</br>
<label for="email">Email:</label> 
<input type="email" name="email" value="<?php echo $email; ?>"/> </br></br>
<label>Title of monument:</label>
<input type="textbox" name="title" value="<?php echo $title; ?>" /></br></br>
<label>Description of monument:</label>

<textarea cols="50" rows="6" name="description" value="<?php echo $description; ?>" /></textarea></br></br>
<label>Select image:</label>
<input type="file" name="file"  ></br></br>
<input type="submit" value="Submit" name="submit" > 
</form> 

最佳答案

替换

textarea cols="50" rows="6" name="description" value="<?php echo $description; ?>" ></textarea>

<textarea cols="50" rows="6" name="description"  ><?php echo $description; ?></textarea>

我在 textarea 元素中添加了 php echo,并从 textarea 值属性中删除了它。 它应该完成工作。

关于php - 无法以 html 形式保存 textarea 的数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22427262/

相关文章:

php - Android php mysql 的 HTTP post 方法

php - Mysql查询插入行不插入行

php - 无法使用 Symfony CLI/Xdebug 进行调试

html - 带图像的页脚将所有文本保留在图像右侧

html - 有很多列时无法固定列宽

javascript - 在 node.js 中使用哈巴狗在表单 "post"之后发送空 {}

c# - 表单内容的控件面板

PHP 和 MySQL - 更改代码 ORDER BY

html - 使用 XSL 文件解析 CDATA block 内的 HTML

c# - 错误消息 “An object reference is required for the non-static field, method or property.”