Jump to content

Securing Variables...


Xiode

Recommended Posts

I have been searching and searching for a fail proof method of securing my variables... I don't know if I have quite gotten there yet...

 

I can use mysql_real_escape_string() to secure $var going into the DB.

 

I can use stripslahes() for stuff coming out fo the DB.

 

What should I use to Secure $_POST and $_GET $vars until they get to the DB?

Should I $var = addslashes($_GET['var']); or $var = htmlspecialchars($_GET['var'], ENT_QUOTES);.

 

But I also should have a separate check for $vars like $id to make sure they are actually a #.

Link to comment
https://forums.phpfreaks.com/topic/46721-securing-variables/
Share on other sites

I use this at the top of every page (using an include):

if(!function_exists(mysql_real_escape_array)) 
{
function mysql_real_escape_array($t)
	{
return array_map("mysql_real_escape_string",$t);
	}
}
mysql_real_escape_array($_GET);
mysql_real_escape_array($_POST);

 

That sanitizes the $_POST and $_GET arrays, so you dont have to do it for every single variable.

Link to comment
https://forums.phpfreaks.com/topic/46721-securing-variables/#findComment-227647
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.