PHP and SQL injection attacks [1] _ PHP Tutorial-php Tutorial

Source: Internet
Author: User
Tags sql injection attack
PHP and SQL injection attacks [1]. Haohappyblog. csdn. netHaohappy2004SQL injection attacks are the most common means for hackers to attack websites. If your site does not use strict user input check, it is very vulnerable to Haohappy
Http://blog.csdn.net/Haohappy2004

SQL injection attacks are the most common means for hackers to attack websites. If your site does not use strict user input tests, it is very vulnerable to SQL injection attacks. SQL injection attacks are usually implemented by submitting bad data or query statements to the site database, which may expose, change, or delete records in the database. Next we will talk about how SQL injection attacks are implemented and how to prevent them.

Let's look at this example:

// Supposed input
$ Name = "ilia '; delete from users ;";
Mysql_query ("SELECT * FROM users WHERE name = '{$ name }'");


Obviously, the command executed by the database is:

SELECT * FROM users WHERE name = ilia; delete from users


This has disastrous consequences for the database-all records have been deleted.

However, if your database is MySQL, you can rest assured that the mysql_query () function does not allow direct execution of such operations (multiple statement operations cannot be performed in a single row. If the database you are using is SQLite or PostgreSQL and supports such a statement, you will face a disaster recovery.

Http://www.bkjia.com/PHPjc/318374.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/318374.htmlTechArticleHaohappy http://blog.csdn.net/Haohappy2004 SQL injection attack is the most common means of hacker attack website. If your site does not use strict user input tests, it is very easy to be accessed...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.