Detailed Explanation of Code
6.1. Introduction
The coding phase translates the design into executable code. It ensures that the system
design is implemented correctly. This phase includes internal documentation using
comments, which are textual notes meant for readers of the program, not for execution.
Well-written code reduces the testing and maintenance effort, aligning with the goal of
minimizing overall project costs.
6.2. Module Coding
6.2.1. [Link]
This script establishes a connection to the MySQL database using PHP. It uses the
`mysqli_connect` function with parameters for the host ('localhost'), username ('root'),
password (empty in this case), and database name ('crime_report'). If the connection fails,
an error message is displayed using `mysqli_connect_error`.
6.2.2. [Link]
This script handles user login for complainants. It checks if the user is already logged in by
verifying a session variable. If not, it processes the login form by validating credentials
against the database. If the credentials are valid and the user is active, the session is
updated, and the user is redirected to their account. Otherwise, an error message is
displayed.
6.2.3. [Link]
This script manages the addition and updating of police officer profiles. It handles image
uploads, form submissions for creating or editing records, and interacts with the database
using SQL queries. Key features include form validation, data insertion, and updates with
error handling.
6.2.4. [Link]
This script displays a list of police stations in a tabular format. It includes features to delete
records and confirm actions using JavaScript. The table is dynamically populated from the
database using a `SELECT` query.
6.2.5. [Link]
This script facilitates the registration of complaints. It includes multiple tabs for collecting
details such as station, complainant information, complaint details, victim details, and
evidence. Uploaded files (photos and videos) are stored, and the data is inserted into the
database. It features robust form handling, validation, and SQL interactions.