Like the subject says I have some $_POST
data that I need to strip all slashes from. However, it leaves behind one and when there are errors on the form it prints the post data back to the user so they do not have to re-enter it. When they submit the page again the number of slashes grows considerably with every submit with errors. The code that I have is straightforward and uses the stripslashes($_POST['first'])
and then sends back errors. I have tried to also str_replace
to get rid of the last \
but this does not work. Any ideas?
Code EDIT--------
$first = stripslashes($_POST[f_name]);
$first = str_replace('\\' , '', $_POST[f_name]);
Do you have magic_quotes enabled? stripslashes will only remove \ that were used to escape a character. So if you WANT a \ in your text, you need to escape it by using two: \. In which case two \ will be converted to one \ with stripslashes. Do a print_r($_POST) before you do any processing to see what is actually in the POST.