Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Keeping textarea data in php

i want to keep a textarea data in php, so when i refresh the page the text is still there. So I tried this, but everytime i refresh the page the text disappears. If someone can help me , i’d be thankful.

PHP code:

<?php 
$comments = "";
$comments= $_POST['comments'];
?> 

HTML code:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

<textarea name="comments" value="<?php echo $comments ?>" cols="30" rows="3" class="w3-input w3-round-large" placeholder="add some infos about yourself !!"></textarea><br>

>Solution :

The textarea doesn’t have a value attribute, so if you want to put a value in there you need to do it in middle of the tags:

<textarea name="comments" cols="30" rows="3" class="w3-input w3-round-large" placeholder="add some infos about yourself !!"><?php echo $comments ?></textarea>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading