Jump to content

config codes


karthikanov24

Recommended Posts

hi

 

This code is about configuration...

Could you explain the following codes...

if (!get_magic_quotes_gpc()) {
if (isset($_POST)) {
	foreach ($_POST as $key => $value) {
		$_POST[$key] =  trim(addslashes($value));
	}
}

if (isset($_GET)) {
	foreach ($_GET as $key => $value) {
		$_GET[$key] = trim(addslashes($value));
	}
}	
}

 

 

thanks

karthikanov24

Link to comment
https://forums.phpfreaks.com/topic/178914-config-codes/
Share on other sites

addslashes used to be helpful when passing data to a database query as it would help escape quotes properly.

 

However, get_magic_quotes_gpc and the code above adds slashes to all input, regardless of whether or not its going to be used within a database query. This is never a good approach.

 

Besides, there are much better ways of cleaning data these days. mysql_real_escape_string for one.

Link to comment
https://forums.phpfreaks.com/topic/178914-config-codes/#findComment-943922
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.