I'm trying to make myself a file manager, and I managed to make an "edit file" function in PHP. In the main page I do have a textarea, but when I want to edit the main page "source", the text stops exactly where the textarea tag closes (</textarea>
)
Here's a representation of the problem:
<textarea><textarea>Hello World.</textarea></textarea>
The textarea output would be
<textarea><textarea>Hello World.
This is because in the code I've closed the textarea tag, but the browser acts like it's been closed from outside the code.
How can I prevent this?
You will need to encode the inner tags like so:
In PHP it's simply a matter of running the file source through
htmlspecialchars()
. A single pass will not alter the output that is displayed in your editor's textarea.