I was on the right track thinking to use htmlspecialchars
, I just needed to take it one step further and also use stripslashes
. This removed the backslashes I were getting from htmlspecialchars
.
So something like:
$content = htmlspecialchars($_POST["textarea"]);
And then when I needed to output it, something like this:
$htmlcode1 = "<html> \n <body>";
$htmlcode2 = "</body> \n <html>";
$somecontent = htmlspecialchars_decode(stripslashes($htmlcode1.$content.$htmlcode2));
Hope this helps someone else out in the future!