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:
<textarea name="comments" value="<?php echo $comments ?>" cols="30" rows="3" placeholder="add some infos about yourself !!"></textarea><br>
CodePudding user response:
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" placeholder="add some infos about yourself !!"><?php echo $comments ?></textarea>