问题
I am trying to keep a textbox and textarea content in its field after a form submission
text Box code:
<div class="response">
<span>
<input class="textbox" id="textbox1" name="textbox1" type="text"
value="<?php if(isset($_POST['textbox1'])) {
echo htmlentities ($_POST['textbox1']); }?>" />
</span> </div>
text area code:
<div class="response">
<span>
<textarea class="textarea" id="textarea1"
name="textarea1" type="text"
value="<?php if(isset($_POST['textarea1'])) {
echo htmlentities ($_POST['textarea1']); }?>" >
</textarea>
</span>
</div>
textbox code is working fine, but I am not able to keep the text area content.
回答1:
You must add code as below,
<textarea class="textarea" id="textarea1" name="textarea1" type="text">
<?php if(isset($_POST['textarea1'])) {
echo htmlentities ($_POST['textarea1']); }?>
</textarea>
Textarea does not have value attribute.
So add PHP
code between opening and closing textarea
tag.
回答2:
try this
<textarea class="textarea" id="textarea1" name="textarea1" type="text">
<?php if(isset($_POST['textarea1'])) { echo htmlentities ($_POST['textarea1']); }?>
</textarea>
来源:https://stackoverflow.com/questions/18653137/keeping-textarea-content-after-a-form-submission