# Technical documentation — clientModule

Evidence date: 2026-10-18. Revision: `master` `aa88a34` (2019-06-24).

Credential values are omitted. Host names, the database name, the MySQL user, and column names below are taken from source.

## What this repository is

A Bitbucket Git repository of a PHP/MySQL client form. Two pages share one mysqli connection. The insert page opens a second connection with the same host switch copied inline. A Smart Admin 2.0 HTML theme is vendored beside them and is not wired to those pages.

There is one branch, `master`. 36 commits, from 2019-06-11 through 2019-06-24. 423 tracked files. 415 of those are under `template/`.

`sonar-project.properties` and `sonarqube_scan.bat` were listed by the onboarding scan and are not in git history.

Authors: Jaco Brits (`jaco@overdrive.co.za`) created the repository. Pieter (`pj@overdrive.co.za`, commit author `SILICONOVERDRIV\pieter`) rewrote the README and added the template. Trevor Mararike wrote the PHP (`trevor@overdrive.co.za`, author names `Trevor Mararike` and `TrevorMararike`).

## Repository layout

```text
clientmodule/
  README.md                 Phase 1–3 task list. Title "Unity : clientModule"
  dbconnection.php          mysqli by SERVER_NAME. Included by the list and edit pages
  projectfunctions.php      print_rr
  formClient.html           Create form and showInput()
  insertClient.php          Prepared insert. Own copy of the connection switch
  displayClient.php         SELECT * list
  editClient.php            Includes the list. Update query commented out
  style.css                 Linked by the form, the list, and the edit page
  template/                 Smart Admin 2.0 static demo
```

No `composer.json`, `package.json`, `Dockerfile`, `bitbucket-pipelines.yml`, `.gitignore`, test directory, or `.sql` file.

## Runtime

| Piece | Evidence |
|---|---|
| Language | PHP. `new mysqli` in both connection sites. `mysqli_query` and `mysqli_fetch_assoc` on the list. Short open tags are not used |
| PHP version | Not pinned. The list script's PHP assignment uses bare constants (`this`, `cells`). That is a notice on PHP 7 and an Error on PHP 8 |
| Database client | `mysqli`. A commented block in `dbconnection.php` still calls `mysql_connect`, `mysql_select_db`, and `mysql_query`. The server product (MySQL or MariaDB) and version are **Unknown** |
| Front end | No framework and no CDN on the application pages. One stylesheet, `style.css`. Validation is an inline function |
| Process model | One request per PHP file. No router or front controller. `formClient.html` is not parsed as PHP |
| Sessions | Not used |
| Debugger | No launch config in git |

The pages assume the web server's document root is the repository root, because links and the form action are `displayClient.php`, `formClient.html`, `editClient.php`, and `insertClient.php` with no directory prefix.

## Database

No schema is committed. Commit messages say a database and a table were created (`7adb18b`, `eb0b3d4`). Those commits change PHP only.

The column list is the insert in `insertClient.php`, plus two columns the list prints and the insert never writes.

| Column | Written by insert | Notes |
|---|---|---|
| `int_ID` | No | Printed as the edit-link text. README asked for auto-increment `per_id`. Whether this column is `AUTO_INCREMENT` is **Unknown** |
| `str_fname` | Yes | From `firstName` |
| `str_lname` | Yes | From `lastName` |
| `str_idNum` | Yes | From `identityNumber` |
| `str_dob` | Yes | From `birthday` (`input type="date"`) |
| `str_gender` | Yes | Posted radio, or `Female` when the key is absent |
| `str_type` | Yes | Posted select value |
| `str_status` | Yes | Posted `Yes`, or `No` when `active` is absent |
| `tms_dateCreated` | No | Printed on the list. README asked for `per_date_created`. Default is **Unknown** |

Historical shapes, not executed at HEAD:

| When | Statement |
|---|---|
| Commented in `dbconnection.php` | `INSERT INTO clients (FirstName, LastName, SAID)` using `mysql_*` and database name `client_module` in that comment |
| `32c01e5` | `INSERT INTO clienttype(type, said, status)` |
| `95ee5ba` | `INSERT INTO tbltype(cli_type, cli_identityNumber, cli_status)` |
| `eb0b3d4` onward | `tbl_client` as above |

Every current bind uses `s` (string). Indexes, nullability, and character set are **Unknown**.

## Connection selection

The same `switch` is in `dbconnection.php` and `insertClient.php`.

| `$_SERVER["SERVER_NAME"]` | Host | User | Password | Database |
|---|---|---|---|---|
| `localhost` | `localhost` | `root` | non-empty, committed in both files, omitted here | `db_clientmodule` |
| `lamp`, and any other name (`default`) | `lamp` | `root` | a different non-empty password, committed in both files, omitted here | `db_clientmodule` |

`dbconnection.php` on failure: `die("Connection failed: " . $conn->connect_error)`. On success: `print_r("connection successful \n")`. The include runs before the list HTML, so that string is the start of the response.

`insertClient.php` on failure: the same `die`. A `print_r` of "Connection was NOT successful" is after `die` and does not run. On success: `print_r("******Connection was Successful******** \n")`.

`projectfunctions.php` is included from `dbconnection.php` only. `print_rr($value)` wraps `print_r` in `<pre>`. The call `print_rr($_SERVER)` is commented out. The insert page never loads this file.

Database name history in the PHP: `client_module` from `4e41169` / `32c01e5`, then `db_clientmodule` from `95ee5ba` (insert page) and `7adb18b` (`dbconnection.php`).

## Request map

| File | Methods that do work | SQL |
|---|---|---|
| `formClient.html` | Browser POST to `insertClient.php` | None |
| `insertClient.php` | POST, unconditional. No submit-button check | Prepared `INSERT` into `tbl_client` |
| `displayClient.php` | Any request that executes the file | `SELECT * FROM tbl_client` |
| `editClient.php` | Any request that executes the file | The include runs the same `SELECT`. The `SELECT` by `int_ID` is a comment |

Insert SQL:

```text
INSERT INTO tbl_client(str_fname, str_lname, str_idNum, str_dob, str_gender, str_type, str_status)
VALUES (?, ?, ?, ?, ?, ?, ?)
```

Bound with `sssssss`. The comment beside the bind says "2 strings and 1 interger".

After `execute`, the script echoes a success paragraph and the seven values, then `header("refresh:5;url=formClient.html")`. Output has already begun, so a default PHP configuration rejects that header.

The commented edit query is:

```text
SELECT * from tbl_client where int_ID = $id
```

`$id` would have come from `$_REQUEST['int_ID']`. Both lines are comments. No `UPDATE` or `DELETE` exists at HEAD.

## Client script

`showInput()` is inline at the bottom of `formClient.html`. It is not in a separate file. The Save button is `onclick="showInput();"`.

Order inside the function:

1. Read `gender` (the male radio) and `status` (the active checkbox).
2. Append a preview to `#results`.
3. Alert and `return false` for an empty or numeric first name, an empty or numeric last name, an ID that fails the 13-digit numeric test, or an empty birthday.
4. Otherwise alert "Posting to Database" and `return true`.

The `onclick` attribute discards the return value. HTML `required` and `maxlength` are the constraints the browser can enforce without that script. First name and last name are not `required`.

`regexp` is assigned `/^[A-Za-z]+$/` and never tested.

The list page's script is a separate inline block. It expects an element id `tbl`. The table id is `tblClient`. PHP embedded in that script assigns `$selectedUser` while the file is included, which is before any click.

## Stylesheet

`style.css` is 40 lines. `formClient.html`, `displayClient.php`, and `editClient.php` link it. `insertClient.php` emits fragments with no stylesheet.

Notable declarations: page background `#faf3e6`, fieldset width 50%, table cell padding `10px` (changed from `15px` in `978e733`), `text-align: centre` (not a CSS keyword), and `font: 15px` with no font family.

## Template

`template/index.html` is "Dashboard | Smart Admin 2.0". Assets live under `template/assets/` (`app.bundle.js`, `app.bundle.css`, `vendors.bundle.js`). Demo pages include login, register, profile, invoice, and gallery HTML that are not the application.

Commit `278eb93` (2019-06-11, Pieter, `#160 Repo udated and setup with template`) added this tree: 416 files in that commit, of which the template is the bulk.

## Security observations

These are properties of the code, recorded so the documentation matches the implementation.

- MySQL passwords for `localhost` and `lamp` are in git, in two files. They are omitted here.
- Both connections use MySQL user `root`.
- Insert is parameterized. The list query does not concatenate input. The commented id filter would have concatenated `$id`.
- The insert response prints POST values into HTML with no encoding.
- A failed connect prints `connect_error` to the client.
- There is no session, CSRF token, or security header in the repository.
- `showInput()` does not stop submit, and the server does not repeat its checks.

## Development and test

No PHPUnit, no fixture, no seed file, and no CI definition. No `.vscode` directory is tracked.

Manual runs implied by the code: a PHP-capable host, with database `db_clientmodule` and a `tbl_client` table that already has the columns above. How that table was created is not in git. `SERVER_NAME` `localhost` selects one credential pair. Any other name selects the `lamp` pair.

Pull request #1 (`e3121e4`, 2019-06-19) is the only merge recorded in commit subjects. It brought stylesheet edits from a Bitbucket online-edit branch.

## Monitoring, jobs, storage, deploy

Not present: cron, queues, workers, object storage, log configuration, health checks, Docker, and a pipeline. Sonar files named by the scan host are not in this revision.

`dbconnection.php` and `insertClient.php` print connection text on every successful request. That is the only operational signal in the application.

## File sizes

The application files are short: `formClient.html` 95 lines, `displayClient.php` 68, `dbconnection.php` 57, `insertClient.php` 56, `style.css` 40, `editClient.php` 22, `projectfunctions.php` 9, `README.md` 34. The bulk of the repository is the unused theme (`template/assets/app/app.bundle.css` and the vendor bundle).
