Show html code from php string in textarea

User avatar
JanMolendijk
Posts: 63
Location: Holland Rotterdam

Show html code from php string in textarea

I wanna add text into an textarea where i have html code into the title but it does not show the whole html code into the textarea.

Code: Select all

Title: <textarea required name="title"  rows="7" value="'. $row[title] .'"></textarea><br>

Admin
If you want to show the html code as it is in string, apply the htmlentities() function to the string with html code.

Code: Select all

Title: <textarea required name="title"  rows="7">'. htmlentities($row[title]) .'</textarea><br>

JanMolendijk
I tried but the textarea field stays empty
jan-molendijk.16mb.com/Test/Comments.php

Admin
There are errors in html code, and no textarea; which means you modified wrong the html code in the php script.

JanMolendijk
Now i did this but still nothing

Code: Select all

Title: <textarea required name="title" rows="7" value="'. htmlentities($row[title]) .'  ENT_QUOTES, UTF-8"></textarea>

Admin
In <textarea> you not have to add data in "value" attribute, but between starting and ending tags.
Try simple like this:

Code: Select all

Title: <textarea required name="title"  rows="7">'. htmlentities($row[title]) .'</textarea><br>

- If textarea is not show in html page code, the problem is also in another part of the php code where you modified.

Adv. Posts: 01

Similar Topics