CLOSE

SQL Injection Explained

SQL Injection Explained

Learn how SQL Injection works with real examples and a hands-on demo using PHP and MySQL. Explore a GitHub repo with vulnerable code to safely test and understand this critical web vulnerability.

Have you ever wondered how someone's personal data ends up leaking online?

Whether it's login credentials, credit card information, or entire databases, the internet is filled with stories of shocking data breaches. But how exactly do attackers pull it off?

In this article, we're going to uncover one of the most common and dangerous web hacking techniques: SQL Injection (SQLi). It's a method so simple that even beginners can exploit it — yet powerful enough to bring down major corporations.

What is SQL Injection?

SQL Injection is a web security vulnerability that allows an attacker to interfere with the queries an application makes to its database. It usually occurs when user input is improperly handled, and it gives the attacker the ability to:

  • View data they shouldn't have access to
  • Bypass login systems
  • Modify or delete database records
  • Execute administrative database operations

Simple Example

Suppose you have a login form that takes a username and password and runs this SQL query in the backend:

SELECT * FROM users WHERE username = '$username' AND password = '$password';

If an attacker types the following into the username field:

' OR '1'='1

And anything into the password, the SQL query becomes:

SELECT * FROM users WHERE username = '' OR '1'='1' AND password = '';

Since '1' = ‘1’ is always true, the query logs in the attacker without needing valid credentials.

Hands-On Demo: Try SQL Injection Yourself

You can explore a live vulnerable web app to safely test SQL Injection using PHP and MySQL

Sample Code Repository:

GitHub:The-Jat/SQL_Injection_Demo

This repository includes:

  • A vulnerable login system using PHP + MySQL
  • A secure version using prepared statements
  • Simple HTML frontend
  • Ready-to-run XAMPP-compatible setup

⚠️ Important: Run this demo locally (e.g., in XAMPP, Docker, or a VM). Never host it publicly, as it is intentionally insecure.

Leave a comment

Your email address will not be published. Required fields are marked *