ACM LEARNING

Secure PHP and MySQL fundamentals

Understand input validation, parameterized queries and transactional records.

Open coding playground Developer tools

Complete each lesson, attempt the exercise and compare with the worked answer.

Input validation and escaping

Validate on the server even when the browser validates too. Treat every submitted field as untrusted. Escape output for the context where it appears. HTML escaping does not replace database parameterization.

Practice

What two steps protect a saved title shown in an HTML page?

Review answer

Validate the title length/type on input and HTML-escape it on output.

Sign in to sync progress

Prepared statements

Separate SQL syntax from user data using bound parameters. Do not interpolate a user-supplied identifier or value into a SQL query. Table and sort column names should come from a fixed allowlist.

Practice

Write a query to find one client by ID.

Review answer

$stmt = $pdo->prepare("SELECT * FROM clients WHERE id = ?"); $stmt->execute([$id]);

Sign in to sync progress

Transactions

A transaction makes several related database writes commit together or roll back together. Use it for invoice conversion, payments and stock or ledger postings. A unique source reference also prevents repeated operations from creating duplicates.

Practice

Why must a transfer debit and credit be in the same transaction?

Review answer

If either side fails, both must roll back; otherwise the accounts no longer reconcile.

Sign in to sync progress

All courses

How can we help?

Support centreProject enquiry

Project visual

Open original image ↗

ACM Assistant

Ask about our software, apps, services or support.

Automated assistance. Do not enter passwords, payment details or confidential information. AI mode may send your question to an external provider.

Contact our team

Tell us about your project