keeping textarea content after a form submission

风格不统一 提交于 2019-12-22 18:15:05

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!