Jump to content

Recommended Posts

Does using a post in a form automatically append backslashes to strings that have single quotes? It seems like it is doing it in my code. I am sending it a string that looks like this

 

AU','BR','ET

 

and it is echoing back this when i type

 echo $_POST['variablename'];

 

AU\',\'BR\',\'ET

Link to comment
https://forums.phpfreaks.com/topic/190538-help-with-post/
Share on other sites

Unfortunately, yes. The magic_quotes_gpc setting being ON will cause GET, POST, and COOKIE data to be 'magically' escaped, even if you don't want it to be.

 

You either need to turn the magic_quotes_gpc setting off (it is settable on a PHP_INI_PERDIR basis) or if you cannot turn it off you must use the get_magic_quotes_gpc() function to test if it is on and then use stripslashes() on the data to remove the offending \ characters. You could unconditionally use stripslashes() on the data but that would prevent you from ever having a real \ as part of the data if magic_quotes_gpc is off.

Link to comment
https://forums.phpfreaks.com/topic/190538-help-with-post/#findComment-1004979
Share on other sites

Unfortunately, yes. The magic_quotes_gpc setting being ON will cause GET, POST, and COOKIE data to be 'magically' escaped, even if you don't want it to be.

 

You either need to turn the magic_quotes_gpc setting off (it is settable on a PHP_INI_PERDIR basis) or if you cannot turn it off you must use the get_magic_quotes_gpc() function to test if it is on and then use stripslashes() on the data to remove the offending \ characters. You could unconditionally use stripslashes() on the data but that would prevent you from ever having a real \ as part of the data if magic_quotes_gpc is off.

 

Ty. Just didn't know if POST was supposed to do that. I went ahead and added the stripslashes to the individual area that required it

Link to comment
https://forums.phpfreaks.com/topic/190538-help-with-post/#findComment-1004981
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.