Web Forms, User Inputs, and Databases
Trace how form input travels to the server, is checked and stored as database rows, and explain what a query does with it.
Six boxes where strangers type into your system
The Tulsi Health order screen has six boxes: name, phone, delivery address, medicine, quantity and a prescription photo, followed by a Place order button. Mrs. Gokhale fills them in every month without a second thought, and what she types travels to Tulsi Health's servers and may be kept in its records for years. A screen like this is a web form: a set of boxes on a page where a person enters information, with a button that sends it. Login screens, search bars, sign-up pages and feedback boxes are all forms. For a business, forms are how customers get things done; for a security person, they are the main places where outsiders put text into the system.
Every box on a form is a different kind of input. Some have a fixed shape, some a range, and some, like the address, accept almost any text.
What happens to what you type
Each box on a form is called a field, and the information you put into it is user input: anything that comes from the person using the app. Typed text is the obvious kind, but choices from a list, ticked boxes, uploaded files such as the prescription photo, and even which button was pressed all count as user input. When Mrs. Gokhale taps Place order, the app collects the value of every field and packs them into one request, something like "name = Lata Gokhale, phone = 90000 12345, medicine = Amlodipine 5 mg, quantity = 2". That request travels over HTTPS, the scrambled and protected form of web traffic, to Tulsi Health's server.
What the server does next is called server-side processing: work done on Tulsi Health's own computers rather than on the customer's phone. Think of a railway reservation counter. The clerk takes your filled-in form and, before typing anything into the booking system, checks that the age is a number, that the train exists, and that the date is not in the past. Only then does the booking go in, and only then do you get a ticket.
The checks and rules run on the server, before anything is saved. A failed check means nothing reaches the database.
The server's code for an order works through the same kind of steps. It reads each value and checks its shape: is the phone number exactly ten digits, is the quantity a whole number between 1 and 10, is the PIN code one that Tulsi Health delivers to? It then applies the business rules: is this medicine in stock at the nearest store, and if it is prescription-only, is a photo attached? If everything passes, it saves the order and replies with a confirmation; if anything fails, it saves nothing and replies with a clear message.
The app on the phone may run some of the same checks as you type, turning a box red when the phone number is too short. That is a kindness to the customer, who learns about a mistake immediately. It is not protection, because a request can reach the server without passing through the app at all, so the server must always check for itself.
Follow one order through these steps below. The second version shows a request that skipped the app's own checks, and some steps pause to ask what the server should do.
Databases: tables of rows and columns
A database is an organised collection of information, stored so that it can be found, added to and changed quickly, even when it holds millions of records. Most business databases keep information in tables, which look like a register or a spreadsheet. Each row is one thing, such as one customer or one order, and each column is one detail about it, such as the phone number or the status. A chemist's handwritten prescription register works the same way: one line per sale, with columns for date, patient, medicine and doctor.
Here are three rows from Tulsi Health's orders table, with made-up numbers:
| order_id | phone | medicine | quantity | status |
|---|---|---|---|---|
| 4519 | 90000 12345 | Metformin 500 mg | 2 | Delivered |
| 4520 | 90000 67890 | Paracetamol 650 mg | 1 | Packed |
| 4521 | 90000 12345 | Amlodipine 5 mg | 2 | New |
Tulsi Health's database holds separate tables for customers, orders, prescriptions, stock in each store and staff accounts. Together they describe 2.4 lakh customers: who they are, where they live and which medicines they take. That is why the database is the part attackers most want to reach, and why everything that flows into it from a form deserves care. A single bad value saved today, such as a wrong address or a quantity of 500, can also travel onwards into delivery lists, bills and stock reports for months.
Asking the database: queries
A program talks to a database by sending a query: a request written in a language the database understands. Most business databases use a language called SQL (Structured Query Language, often said "sequel"). You do not need to write SQL to follow the idea, because almost every query does one of four simple jobs.
Find, add, change and remove. Every screen in the app is built from these four requests to the database.
When Mrs. Gokhale opens her order history, the backend sends a find query. In plain English and then roughly as SQL, it looks like this:
Plain English: find the medicine and status of every order where the phone is 90000 12345
SQL (roughly): SELECT medicine, status FROM orders WHERE phone = '90000 12345'
Notice where the phone number in that query came from: it is Mrs. Gokhale's own input, taken from a form field and placed inside an instruction to the database. That is what makes forms so useful, because the same code can serve every customer by slotting in their own details. It is also what makes them risky. A database follows the instructions it receives exactly, so the backend has to make sure that whatever a customer types is only ever used as a detail to look up or store, and can never change what the instruction itself asks for.