mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 08:58:56 +00:00
Replaced insecure example with a better one.
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@298138 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
95225913b7
commit
108dfaacbf
1 changed files with 7 additions and 3 deletions
|
@ -46,12 +46,16 @@ echo get_magic_quotes_gpc(); // 1
|
|||
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')";
|
||||
?>
|
||||
|
|
Loading…
Reference in a new issue