我使用 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/