PHP prevents SQL injection

WBOY
Release: 2016-07-25 08:44:22
Original
1110 people have browsed it
  1. /*
  2. Sometimes there is more than one variable submitted in the form, maybe a dozen or dozens. So is it a little troublesome to copy/paste addslashes() again and again? Since the data obtained from the form or URL appears in the form of an array, such as $_POST, $_GET), then customize a function that can "sweep the army"
  3. */
  4. function quotes($content)
  5. {
  6. //If magic_quotes_gpc=Off, then start processing
  7. if (!get_magic_quotes_gpc()) {
  8. //Determine whether $content is an array
  9. if (is_array($content)) {
  10. //If $content is an array, then Process each of its elements
  11. foreach ($content as $key=>$value) {
  12. $content[$key] = addslashes($value);
  13. }
  14. } else {
  15. //If $content is not an array , then it will only be processed once
  16. addslashes($content);
  17. }
  18. } else {
  19. //If magic_quotes_gpc=On, then it will not be processed
  20. }
  21. //Return $content
  22. return $content;
  23. }
  24. ?>
Copy code

php, SQL


Related labels:
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template