开发者

Slash appended to all my posts [duplicate]

开发者 https://www.devze.com 2023-04-04 16:12 出处:网络
This question already has answers here: Closed 11 years ago. Possible Duplicate: Why turning magic_quotes_gpc on in PHP is considered a bad practice?
This question already has answers here: Closed 11 years ago.

Possible Duplicate:

Why turning magic_quotes_gpc on in PHP is considered a bad practice?

when i get information from a post form, the html form adds slashes before random characters. for example: hello "george" becomes hello \"george\".

I dont understand at all why this happens, I tried already forbidding slashes in the input tag from开发者_JAVA技巧 javascript but does not work so I need some php or javascript function to remove this from the server. The function must work in html too because i am using these three technologies because i am developing and selling web 2.0 sites.

what is the php function for this and its version for html too? thanks in advance.

Here I link you to my pages with this problem, maybe you can check why this happens.

http://www.nickersonweb.com/

http://www.preferredmerchantservices.net/


This is an old (deprecated) feature of PHP that automagically escapes some characters in strings from various sources ($_GET, $_POST, $_COOKIE, etc).

The goal was to protect from SQL injection vulnerabilities, but this was not that good.

This can be disabled by setting the magic_quotes_gpc setting to 0 in your php.ini.

If you don't have control over the magic_quotes_gpc setting, you may want to reverse its effect, by using the stripslashes function:

$value = stripslashes($_POST['foo']);

You can do it on all $_POST variables like this:

function stripslashes_r($value) {
    if (is_array($value)) return array_map('stripslashes_r', $value);
    else return stripslashes($value);
}

if (get_magic_quotes_gpc()) {
    $_POST = stripslashes_r($_POST);
}


special characters are escaped. you can remove the backslashes with http://php.net/manual/en/function.stripslashes.php

0

精彩评论

暂无评论...
验证码 换一张
取 消