PHP開発でget_magic_quotes_gpc関数を利用するソースコード
PHPコード:
<html>
<!–POSTで単一引用符号を渡す –>
<body>
<form action="first.php" method="post">
<input type="text" name="startnews24_lastname" value="startnews24’it and game">
<input type="submit" value="確認">
</form>
</body>
</html>
<?php
echo get_magic_quotes_gpc(); // 0
echo $_POST['startnews24_lastname’]; // startnews24’it and game
echo addslashes($_POST['startnews24_lastname’]); // startnews24\’it and game
if (!get_magic_quotes_gpc()) {
$startnews24_lastname = addslashes($_POST['startnews24_lastname’]);
} else {
$startnews24_lastname = $_POST['startnews24_lastname’];
}
echo $startnews24_lastname; // startnews24\’it and game
$sql = “INSERT INTO startnews24_lastnames (startnews24_lastname) VALUES ('$startnews24_lastname’)";
?>