note 21321 added to security.database

From: Date: Wed, 08 May 2002 12:03:03 +0000
Subject: note 21321 added to security.database
Groups: php.notes 
Request: Send a blank email to php-notes+get-30329@lists.php.net to get a copy of this message
Very informative, I cannot stress enough to validate all input you are passing to an SQL query. If you expect an int, use is_int(), if it's a fractional number, use is_float(), for example: if(!is_int($_POST['var'])) { die('Invalid input'); exit; } If it's a string do: if(!get_magic_quotes_gpc()) { $_POST['var'] = addslashes($_POST['var']); } To avoid people manipulating the query string, as shown above. If "magic quotes" is enabled the form input info will automatically have slashes added, you only need to do it if PHP isn't set up to use "magic quotes". Be very careful, I have made alot of mistakes with SQL queries in the past. -- http://www.php.net/manual/en/security.database.php http://master.php.net/manage/user-notes.php?action=edit+21321 http://master.php.net/manage/user-notes.php?action=delete+21321 http://master.php.net/manage/user-notes.php?action=reject+21321

« previous php.notes (#30329) next »