I have a form that is used to cut'n'paste paragpaphs of text in to a database. The text may have line breaks, paragraph breaks, all sorts of special characters, anything from single and double quotes to trademarks, degrees and such.
Currently I encode this text and decode it on output by using the following code:
// input into db
if($_POST["myText"]) {
$dbText=urlencode($_POST["myText"]);
}
else {
$dbText=$myText;
}
// output from db
echo urldecode($dbText);
Question, is there a better way of doing it?