svn: /phpdoc/en/trunk/reference/info/functions/ get-magic-quotes-gpc.xml

From: Date: Sun, 18 Apr 2010 08:39:04 +0000
Subject: svn: /phpdoc/en/trunk/reference/info/functions/ get-magic-quotes-gpc.xml
Groups: php.doc.cvs 
Request: Send a blank email to doc-cvs+get-6394@lists.php.net to get a copy of this message
degeberg Sun, 18 Apr 2010 08:39:04 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=298138 Log: Replaced insecure example with a better one. Changed paths: U phpdoc/en/trunk/reference/info/functions/get-magic-quotes-gpc.xml Modified: phpdoc/en/trunk/reference/info/functions/get-magic-quotes-gpc.xml =================================================================== --- phpdoc/en/trunk/reference/info/functions/get-magic-quotes-gpc.xml 2010-04-18 08:12:51 UTC (rev 298137) +++ phpdoc/en/trunk/reference/info/functions/get-magic-quotes-gpc.xml 2010-04-18 08:39:04 UTC (rev 298138) @@ -46,12 +46,16 @@ echo $_POST['lastname']; // O\'reilly echo addslashes($_POST['lastname']); // O\\\'reilly -if (!get_magic_quotes_gpc()) { - $lastname = addslashes($_POST['lastname']); -} else { +if (get_magic_quotes_gpc()) { + $lastname = stripslashes($_POST['lastname']); +} +else { $lastname = $_POST['lastname']; } +// If using MySQL +$lastname = mysql_real_escape_string($lastname); + echo $lastname; // O\'reilly $sql = "INSERT INTO lastnames (lastname) VALUES ('$lastname')"; ?>

« previous php.doc.cvs (#6394) next »