-Magic quotes of PHP
A function called magic quotes was previously created in PHP 6 to help protect novice programmers from writing bad table processing code. Magic quotes automatically avoids dangerous form data and may be used for SQL injection with a backslash. PHP escape characters include quotation marks, double quotation marks, backslash, and NULL characters.
Tizag.com
However, this newbie protection proves that more problems are caused than solved, rather than in PHP 6. If any version of your PHP version is 6 days ago, you should use this lesson to learn how magic quotes may affect you.
Magic quotes-what do they make?
First, you need to check if you have magic quotes to make your server. The get_magic_quotes_gpc function returns 0 (off) or 1 (on ). These Boolean values are suitable for making a good speech. If 1 is true, 0 is false.
If (get_magic_quotes_gpc ())
Echo "Magic quotes are enabled ";
Else
Echo "Magic quotes are disabled ";
The output is related to whether php is enabled.
Magic quotes in action
Now you can make a simple form to show how processor machines with magic quotes will enable those who may escape danger. This form is submitted to yourself, so you only need to make a file, "Magic quotes. php" to test it.
<? Php
Echo "Altered Text:". $ _ POST ['question'];
?>
<Form method = 'post'>
Question: <input type = 'text' name = 'question '/> <br/>
<Input type = 'submit '>
</Form>
Remove the backslash-s tripslashes () function
When using PHP's backslash clearing function stripslashes, it intelligently adds some magic quotes like our check ", are they enabled? . In this way, you will not be accidentally deleted as the slash is legal. In the future, if your PHP magic quotes settings change in the future.
<? Php
Echo "Removed Slashes :";
// Remove those slashes
If (get_magic_quotes_gpc ())
Echo stripslashes ($ _ POST ['question']);
Else
Echo $ _ POST ['question '];
?>
<Form method = 'post'>
Question: <input type = 'text' name = 'question '/> <br/>
<Input type = 'submit '>
</Form>