PHP Network Development Detailed: SQL injection vulnerability

Source: Internet
Author: User
SQL injection is a common tactic of network attacks, where an attacker can get a management account, password, and more information by pooling the SQL statements in the page. This attack Method The harm to the website is very big.

general approach to SQL injection attacks

The following code is a simple data output page that is passed from the Browser The address bar gets the parameters to display the appropriate content.
<?php
$id = $_get[' id ']; Get parameters
$sql = "SELECT * from posts WHERE PostID = $id"; Defining SQL
mysql_connect ("localhost", "root"); Connecting to a server
mysql_select_db ("guestbook"); Connecting to a database
$rs = mysql_query ($sql); Execute SQL
if (Mysql_numrows ($RS))//If the record exists, the output
{
$row _rs = Mysql_fetch_assoc ($RS);
echo "TOPIC:". $row _rs[' TOPIC ']. " <br> ";
}
else </

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.