Jump to content

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

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.