php - $_POST and $_GET convert quote( ' ) to backslash + quote ( \' ) -
i have code :
<?php echo $_get['user']; ?> <html > <head> </head> <body> <form method = "get" action="file.php"> <input type = "text" name = "user"><br> <input type = "submit" value ="submit"><br> </form> </body> </html>
when type '
in textbox prints out \'
instead of '
.
example if type 'hello'
prints out \'hello\'
.
how can fix ??
the slashes added because have magic_quotes_gpc=on
in php.ini
. note feature depreacted , should turn off in php.ini
. former security feature should not rely on it. instead write code valides all inputs , use prepared statements when pass inputs sql queries or use escapeshellarg()
if pass inputs shell scripts.
however, use stripslashes()
remove slashes:
echo stripslashes($_get['user']);
Comments
Post a Comment