What is SQL Injection?

Hello everyone,

Open your website and go to the Login page.

  • Enter any value as the username.
  • For the password, enter the following text:
' or '1'='1

If the website allows you to log in without a valid username and password, then there is a serious problem in the login code.

This problem is called SQL Injection.

What is SQL Injection? (Beginner Explanation)
  • Websites use a database to store usernames and passwords.
  • The login page sends user input (username and password) to the database.
  • If the input is not properly checked, an attacker can enter special characters.
  • These characters can change the meaning of the database query.
  • As a result, the database may return data without proper authentication.

In simple words:
SQL Injection happens when user input is trusted blindly and used directly in database queries.

Why is SQL Injection Dangerous?
  • Anyone can log in without a password
  • Sensitive data can be exposed
  • Data can be modified or deleted
Important Note for Students

This example is shared only for learning and testing your own code.
You should use this knowledge to fix security issues, not to misuse websites.

A secure login page must:

  • Validate user input
  • Use prepared statements or parameterized queries

Basics of database

Basic Terms
  • Data
    Data means raw facts.
    Example: Sonu, 25, Delhi
  • Information
    Information is processed data that has meaning.
    Example: Sonu is 25 years old and lives in Delhi.

Table Basics
  • A table is a collection of rows and columns.
  • Tables are used to store data in an organized way.

Database Terminology

In database language:

  • Table is called a Relation
  • Row is called a Tuple
  • Column is called an Attribute

Database

A database is a collection of one or more tables.

A database can contain:

  • Tables
  • Views
  • Triggers
  • Other database objects

RDBMS

RDBMS (Relational Database Management System) is a type of software used to create and manage databases.

Key points about RDBMS:

  • It stores data in the form of tables
  • Tables can be related to each other
  • It helps to store, retrieve, update, and delete data easily

Popular RDBMS Software

Some commonly used RDBMS are:

  • Oracle
  • Microsoft SQL Server
  • DB2
  • MySQL
  • PostgreSQL

... means the list is very long and cannot be shown completely.


SQL

All the RDBMS listed above use SQL.

  • SQL stands for Structured Query Language
  • SQL is used to create and manage databases
  • SQL is a standard language
  • SQL is easy to learn because it is close to English
  • SQL is a 4th generation language

What is class and object?

In Object-Oriented Programming (OOP), we often hear two important terms:
Class and Object.

Let us understand these terms in a very simple way.


Example: Mobile Phone

Imagine the CEO of Samsung plans to launch a new mobile phone after 2 years.
Before manufacturing starts, the CEO discusses the features and functions of the mobile with the team.

Future Mobile: Samsung SG-786
Features (Attributes)
  • Screen size = 3.5 inch
  • Touch screen = Yes
  • Number of buttons = 7
  • Charging points = 2
  • Color = Red / Silver / Black

( means the list is long)

Functions (Behavior)
  • Make a call
  • Receive a call
  • Send SMS
  • Receive SMS

  • Alarm
  • Calculator
  • Stopwatch

Class and Object Explanation

To manufacture the mobile phone, all the above details are sent to the factory.

  • These specifications (features + functions) are called a Class.
  • When the factory produces 10,000 mobile phones using these specifications,
    each mobile phone is called an Object.

So:

  • Class → Design / Blueprint / Template
  • Object → Real product created from the class

One More Simple Example

Suppose you have one house blueprint.

  • The blueprint is a Class
  • If you build two houses using the same blueprint,
    those houses are Objects

Class in Programming

When we write a program:

  • Attributes are called Fields or Member Variables
  • Behavior is written as Methods (Functions)

A class contains:

  • Fields (data)
  • Methods (actions)

An object uses the class to work.


In short:

  • Class = Blueprint
  • Object = Instance of the class

Hope this makes the concept of Class and Object clear for beginners.