Click here to Skip to main content
15,888,610 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi i'm not sure if using the below php in textarea

PHP
<textarea class="form-control" name="note_text" rows="7" placeholder="...">
 <?php echo htmlentities($this->note->note_text); ?>
</textarea>


is there another way to do so?

reason why I use htmlentities is because to prevent user input with " etc. break the HTML

Just so you are aware this is a form for editing a saved note in database

What I have tried:

I have tried this but displays weirdly in center of text area

PHP
<textarea class="form-control" name="note_text" rows="7" placeholder="...">
 <?php echo htmlentities($this->note->note_text); ?>
</textarea>
Posted
Updated 13-Feb-17 1:50am
Comments
W Balboos, GHB 7-Feb-17 11:00am    
What does "displays weirdly" mean? Example, please!

It wouldn't be bad if you showed what you wanted to get vs. what you're getting.
Member 11838038 13-Feb-17 3:06am    
Hi,

Sorry for delayed response,

What I meant was that the text is being displayed in the centre of the textarea also when using example input name="text_name" value="<?php echo htmlentities($this->note->note_text); ?>"
It would display hundreds and can submit data but when not using value="" its not allowing me to submit data. does textarea not support value="" do you have to use it within the textarea tags? <?php echo htmlentities($this->note->note_text); ?>

1 solution

Since your problem happens by what (I think) you describe as a blank text area, you should check what value is sent from that control when you submit it as blank.

If it's a NULL and not an empty string, you are probably causing some errors. A NULL value is not an empty string [see this] [^].

Perhaps something like:
PHP
<?php
  if(!isnull($this->note->note_text))
    echo htmlentities($this->note->note_text);
  else
    echo ""; // or whatever you want to do with an empty box
?>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900