PHP urlencode 和解码
所有,
有一个文本区域说
<input type="submit">
如果用户输入为,
here is my name and my mail id is "[email protected]"
并且当数据发布到服务器端时,数据将被接收为 这是我的名字,我的邮件 ID 是 \"[电子邮件受保护]\ "
在双引号后面添加反斜杠。现在如何在提交之前对数据进行编码。我在服务器端使用 php..
谢谢。
All,
There is a text area say
<input type="submit">
And if a user gives the input as,
here is my name and my mail id is "[email protected]"
And when the data is posted on the server side the data is received as
here is my name and my mail id is \"[email protected]\"
Backslash is added behind double quotes.Now how to encode the the data before submitting.I am using php on the server side..
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
这是 magic_quotes_gpc 的作用 - 要删除它只需在 php.ini 中禁用它或使用 stripslashes($your_var) 删除它;
尽管请记住,这是 php 的一个(糟糕的)安全功能,但是当将数据存储到数据库时,您应该使用相应的转义函数来防止 sql 注入,并且当显示用户发布的数据时,您的清理函数应该防止 xss 注入。
this is magic_quotes_gpc kicking in - to remove it just disable it in php.ini or remove it using stripslashes($your_var);
though bear in mind that this is a (lousy) security feature of php, but when storing the data to a database you should use the respective escape functions to prevent sql injections anyway and when showing user-posted data your sanitizing function should prevent xss injections.
它看起来像指令
magic_quote_gpc< /code>
在您的服务器上启用:
A solution, if you can't disable it in your server's configuration, would be to :
stripslashes 从输入中删除转义
关于这一点,您可以阅读 部分禁用魔术引号。
Of course, you'll have to escape your data properly before using it ; for instance, before injecting it into an SQL query.
It looks like the directive
magic_quote_gpc
is enabled on your server :A solution, if you can't disable it in your server's configuration, would be to :
stripslashes
About that, you can read the section Disabling Magic Quotes.
Of course, you'll have to escape your data properly before using it ; for instance, before injecting it into an SQL query.
如果您的网络托管提供商不允许您在 php.ini 文件中禁用它,您也可以在 PHP 中删除魔术引号。将此代码放在 PHP 脚本之上:
You can get rid of magic quotes also in PHP if your web hosting provider doesn't allow you to disable it in php.ini file. Put this code on top of your PHP script:
在 php.ini 中禁用 magic_quotes 或在 PHP 中使用
stripslashes($text)
来删除斜杠。Disable magic_quotes in php.ini or use
stripslashes($text)
in PHP to remove slashes.您的系统上可能启用了魔术引号。这不是一件好事。
You probably have magic quotes enabled on your system. This is not a good thing.