-7

What is SQL injection? Please give me a real time example.

Alex Myers
  • 4,257
  • 7
  • 17
  • 33

2 Answers2

1

The wiki says that:

SQL injection is a code injection technique, used to attack data driven applications, in which malicious SQL statements are inserted into an entry field for execution (e.g. to dump the database contents to the attacker).1 SQL injection must exploit a security vulnerability in an application's software, for example, when user input is either incorrectly filtered for string literal escape characters embedded in SQL statements or user input is not strongly typed and unexpectedly executed. SQL injection is mostly known as an attack vector for websites but can be used to attack any type of SQL database.

Rahul Tripathi
  • 152,732
  • 28
  • 233
  • 299
0

User input that deliberately contains SQL code to do harmful things, and isn't disabled or sanitized by the code. E.g.,

$who = $_GET['customer_id'];
 ...
DELETE from records WHERE customer_id = '$who'

could be injected with something similar to customer_id=1234' and 1=1 and ''=', resulting in

DELETE from records WHERE customer_id = '1234' and 1=1 and ''=''

resulting in all records in the table being deleted. It could be sanitized by escaping all ' in the user input.

Phil Perry
  • 2,078
  • 12
  • 18