🚧 Under construction — VoTechWorks is being built. A free tech program — complimentary, as our commitment to get America working.
voTechWorksGrade 13 · a vocational technology learning center, by urbanicity
newSchoolWorks.com › VoTechWorks › Technology & Design › Web & Software Development › PHP and Python Web Programming › Lesson 12
TEC-WEB46-03 · Lesson 12 · 28 clock hours · practice

Integrated Project: Dynamic PHP and Python Web Application

Objective. Students design, build, test, and document a multi-page web application that uses PHP for the front-end server logic and a Python script for back-end data processing or automation, connected to a MySQL/MariaDB database with secure coding practices applied throughout

⚠ Pending professional review

This lesson, its worked examples and its practice questions has not yet been verified by an industry-certified professional or by a certification or approval body. It is a study draft and may contain errors. Do not use it as instructions for work on a job site or on live equipment. Always follow your instructor, your supervising professional, and current official references and regulations.

VoTechWorks program approval and accreditation are still in progress. Credentials are issued only by the certifying bodies named in each program, after their own exams.

Integrated Project: Dynamic PHP and Python Web Application

This lesson brings together every skill you have built in this course. You will design, build, test, and document a multi-page web application that uses PHP for front-end server logic, a Python script for back-end data processing or automation, and a MySQL or MariaDB database — all held together by secure coding practices.

Planning Before You Code

Rushing into code without a plan is the single most common reason student projects fail. Before writing one line of PHP or Python, produce a written project brief that contains three things.

Data dictionary. List every database table you plan to create. For each table, record the column name, data type (for example, `INT`, `VARCHAR(100)`, `DATE`), whether the column can be NULL, and any key constraints (primary key, foreign key, unique). A clear data dictionary prevents column-name typos and type mismatches that are painful to fix later.

Site map. Sketch at least four PHP pages and the links between them. Common pages include a login page, a dashboard or home page, a data-entry form page, and an admin or report page. The site map helps you see the user's path through the application before you build it.

Python component description. Write one paragraph explaining exactly what your Python script will do, what data it reads (from the database, a file, or an API), what it produces, and when or how it is triggered. Your instructor must approve the brief before you begin the build phase.

Build Phase: PHP, Python, and the Database

PHP pages. Each PHP page should follow a consistent structure: include a shared header file, check session state where required, validate and sanitize all user input, run parameterized queries against the database, and render output safely. Never interpolate raw user input into a SQL string — use PDO or MySQLi prepared statements with bound parameters. This is the primary defense against SQL injection.

For session management, call `session_start()` at the top of every page that needs it, store only a user ID in the session (not the password), and regenerate the session ID after a successful login with `session_regenerate_id(true)` to prevent session fixation attacks.

For output, always encode user-supplied data before printing it to the browser. In PHP, `htmlspecialchars($value, ENT_QUOTES, 'UTF-8')` converts special characters to HTML entities, blocking cross-site scripting (XSS) attacks.

CRUD operations. Your application must support Create, Read, Update, and Delete operations against at least one database table. Wrap multi-step operations in database transactions so partial failures do not leave corrupt data.

The Python script. Python handles the back-end work — for example, reading records from the database and generating a CSV report, sending a summary email, or running a data cleanup routine. Use the `mysql-connector-python` or `PyMySQL` library to connect to the same database your PHP pages use. Always close the connection when the script finishes. Never hard-code credentials in the script; read them from a configuration file that is excluded from version control via `.gitignore`.

Git discipline. Commit your code to a local Git repository at the end of every lab session with a meaningful commit message (for example, `Add input validation to registration form`). You need at least eight commits by the end of the project. A well-maintained Git log is evidence of your workflow and protects you if a file is accidentally deleted.

Secure Coding Practices Throughout

OWASP (Open Worldwide Application Security Project) publishes the OWASP Top Ten, a widely used reference list of the most critical web application security risks. For this project, focus on the following risks:

Store no plaintext passwords — ever. If your project requires user accounts, hash the password at registration and verify the hash at login.

Testing and Documentation Phase

A written test plan with at least ten test cases is required. Each test case must state: an ID, the feature being tested, the input you will enter, the expected result, the actual result, and pass or fail. Cover three categories:

Record every bug you find and the fix you applied. This bug log is part of your submitted documentation.

Finish with a README file (plain text or Markdown) that explains how to set up the database, configure credentials, install PHP and Python dependencies, and run the application. A reader who has never seen your project should be able to get it running by following your README alone.

Passing Criteria

All of the following must be true to earn a passing grade: all ten test cases pass; instructor review finds no SQL injection or XSS vulnerabilities; the Python script runs without errors and produces correct output; the README is complete and accurate; and the Git log shows at least eight commits. Every criterion must be met — there is no partial credit on this integrated project.

Key terms8

Data dictionaryA document that defines every table, column, data type, and constraint in a database, serving as the authoritative reference for the database schema during development.
Prepared statementA parameterized database query in which user-supplied values are bound separately from the SQL text, preventing SQL injection by ensuring the database never interprets input as code.
Session fixationAn attack in which an adversary forces a known session ID on a user before login; mitigated in PHP by calling session_regenerate_id(true) immediately after a successful login.
XSS (Cross-Site Scripting)An attack in which malicious scripts are injected into web pages viewed by other users; prevented by encoding all user-supplied output with htmlspecialchars() before rendering it in HTML.
CRUDThe four basic database operations: Create, Read, Update, and Delete; a complete web application typically exposes all four through its user interface.
OWASP Top TenA regularly updated reference list published by the Open Worldwide Application Security Project that identifies the most critical web application security risks and recommended mitigations.
Password hashingThe process of transforming a plaintext password into a fixed-length digest using a one-way function such as bcrypt; PHP provides password_hash() and password_verify() for this purpose.
Test caseA documented scenario that specifies a feature, input, expected result, actual result, and pass/fail status, used to verify that an application behaves correctly under defined conditions.
In class: Project planning phase (hours 1–6): students produce a written project brief including a data dictionary (table names, columns, data types), a site map of at least four PHP pages, and a description of the Python component's role — instructor must approve the brief before coding begins · Build phase (hours 7–22): students implement all PHP pages (including login/session management, CRUD operations, and input validation), the Python automation or processing script, and the database; they commit code to a local Git repository at the end of each lab session and document progress in their lab log · Testing and documentation phase (hours 23–28): students conduct structured testing using a written test plan with at least ten test cases covering normal, boundary, and error conditions; they document all bugs found and fixes applied, and submit a final README that explains how to install and run the application
Materials: PHP manual, Python 3 docs, MySQL/MariaDB, VS Code, Git (local), OWASP references, student lab log and project brief templates
Check: Application passes all ten test cases; no SQL injection or XSS vulnerabilities found by instructor review; Python script runs and produces correct output; README is complete and accurate; Git log shows at least eight commits — all criteria must be met to pass

Practice check8

Answer each question, then check it. Nothing is recorded; this is your own practice.

Secure coding / application security
1. A student's PHP registration form inserts the value of $_POST['username'] directly into a SQL string using string concatenation. Which security vulnerability does this create?
Secure coding / application security
2. Which PHP function should be called immediately after a user successfully logs in to prevent session fixation attacks?
Secure coding / application security
3. A student wants to display a product description that was entered by a user and stored in the database. Which PHP function should wrap the output to prevent XSS?
Development workflow / security
4. According to the project requirements, why must database credentials be excluded from the Git repository?
Software testing
5. A student's test plan must include at least ten test cases covering normal, boundary, and error conditions. Which of the following is the best example of a boundary test case for a registration form that requires a username of 3–20 characters?
Database design / project planning
6. What is the primary purpose of a data dictionary in the project planning phase?
Secure coding / Python development
7. A Python script needs to connect to a MariaDB database. Which approach best protects the database password?
Development workflow / version control
8. The project pass criteria state that the Git log must show at least eight commits. What does a well-maintained commit history primarily demonstrate?
Record this lesson on my transcript. Sign in with your key and enrollment email to record lessons (enroll free if you have no key). This page stays open to read and practise.