john_zakaria — 2012-01-11T03:27:55-05:00 — #1
i have a form for exam where the user can enter data in text field with any special character (quote ('), double quote ("), backslash (\))
so i use addslashes in post then i echo the field using stripslashes and everything till this point is OK.
my problem is that the answer may contains a slash in the text field e.g: jo\hn
but when i tried to echo it using stripslashes it echos "john" which is wrong.
i used addslashes and addcslashes to try fix this error but it still exists
i want to add slashes to all special character except the backslashes "'\" .. so the answer to be as it is "jo\hn"
chris_upjohn — 2012-01-11T03:50:06-05:00 — #2
You could try using [htmlspecialchars() instead which converts any special character into a HTML entity, you could then decode the characters back using [URL="http://www.php.net/manual/en/function.htmlspecialchars-decode.php"]htmlspecialchars_decode()](http://php.net/manual/en/function.htmlspecialchars.php)
guido2004 — 2012-01-11T03:55:37-05:00 — #3
Why? When? When you output to the client? When you save in the database?