Escaped characters in string from submitted form

痞子三分冷 提交于 2019-12-31 05:44:07

问题


Every time a POST is made I get escaped characters.

\ -> \\
' -> \'
" -> \"

I have a multistep form, which transmits the data from one form to another. I save the values with prepared statments in the database. The values in the database currently look like Paul\'s House. User should have the possiblity to use single and double quotes in their string.

This is a simple example demonstrating the escaping effect:

<?php
echo $_POST['value'];
?>
<form action="form.php" method="post" enctype="multipart/form-data">
    <input type="hidden" name="value" value="Paul's House">
    <input type="submit" value="Next">
</form>

Why or who escapes the string? What is the correct way for handling data over multiple forms? What is the correct way for saving it in the database? Should I use stripslashes() or I'm opening a big security hole?


回答1:


Looks like you have Magic Quotes turned on.

http://www.php.net/manual/en/security.magicquotes.disabling.php

Check that out for how to disable.




回答2:


You must turn off the magicquotes in server , otherwise you should very careful about on/off status of the magicquotes .



来源:https://stackoverflow.com/questions/9705758/escaped-characters-in-string-from-submitted-form

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!