Solution to the problem of automatically adding escape characters when passing parameters in PHP form POST

PHP中文网
Release: 2016-07-25 08:56:01
Original
2626 people have browsed it
This article introduces the solution to the problem of automatically escaping characters when passing parameters in the form post method in PHP. Friends in need can learn from it.

Problem description: Enter the mysql statement from the form, and then submit it to the PHP program. The PHP program will make the corresponding query and return the results. When using it, you will find that if there are special characters (such as '' "", etc.) entered in the form, PHP will automatically add them to the form. Add the escape character "" in front of it, but once it is added, you can no longer use this statement to make SQL queries.

Solution: Enter in the form:

select * from device_information where manager_team regexp 'huawei'
Copy after login

After printing it becomes:

select * from device_information where manager_team regexp \'huawei\'
Copy after login

Check the php.ini file, the value of the magic_quotes_gpc option should be on. You can consider using the stripslashes function to solve this problem.

The above is the solution to the problem of automatically adding escape characters when passing parameters in PHP form POST. For more related content, please pay attention to the PHP Chinese website (m.sbmmt.com)!






source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!