keeping textarea content after a form submission

2019-05-23 14:27发布

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.

2条回答
够拽才男人
2楼-- · 2019-05-23 14:51

try this

        <textarea  class="textarea" id="textarea1" name="textarea1" type="text">
        <?php if(isset($_POST['textarea1'])) {  echo htmlentities ($_POST['textarea1']); }?>
    </textarea>
查看更多
对你真心纯属浪费
3楼-- · 2019-05-23 15:03

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.

查看更多
登录 后发表回答