Any Guesses! Anyone.. Anyone.. I had 14 reads and no posts the first time I posted this, can anyone help. Please 🙂
Need a solution that will take care off all special characters in a text input field after it is submitted to DB. I need to assume that they may type in anything. I have tried using different combinations of reg_exp, addslashes, stripslashes, and quotemeta, but I seem to be in a Catch22 now. Either all "special characters have a slash in front of them when I redisplay the info, (BUT $ look correct and dollar amount is displayed correctly) or I strip slashes and then loose the $ and the digits follwing up to the decimal.
Thanks For any help
if (isset($_POST["comments"])) {
RAW VALUE FROM FORM POST
$comments = $_POST["comments"];
FILTERING FOR DB INSERTION
$dbComments = stripslashes($comments);
$dbComments = quotemeta($dbComments);
$dbComments = urlencode($dbComments);
$dbComments = stripslashes($dbComments);
FILTERING FOR EMAIL COPY TO BE SENT
$eComments = quotemeta($comments);
$eComments = preg_replace("/\r/", '\n', $eComments);
FILTERING FOR DISPLAY ON CONFIRMATION PAGE
$dComments = stripslashes($comments);
$dComments = quotemeta($dComments);
$dComments = preg_replace("/\r/", '<br>', $dComments);
In the end I will either end up with one of the following:
Comments Read: I have a \? about my $10.00
or
Comments Read: I have a ? about my .00
Thanks
Adam