CASE FILE 12/13CLASS: SAMPLE BUILDDATA: REALISTIC, NOT CLIENTTYPE: Websites & scripts
Sample build: realistic data, built to show how I'd handle this work. Not client work.
Sample buildWebsites & scripts
PHP booking form with server-side validation and invoicing
A PHP booking form that prices, invoices and refuses double bookings: 24/24 tests pass
- 24/24tests pass
- 5PHP files
- 243lines of PHP
- 0double bookings allowed
01Summary
- A booking form in plain PHP (5 files, 243 lines) validates every field on the server.
- Each confirmed booking gets an invoice with net, 10% tax and a due date, and a slot can never be booked twice.
- 24 of 24 automated tests pass.
Each confirmed booking gets an invoice with net, 10% tax and a due date, and a slot can never be booked twice.
Key point, computed from the sample files
02The scenario
In this scenario bookings arrive by email, two people sometimes get the same slot, and invoices are typed up later.
Source: sample files
03Issues in the data
Source: sample files
04How I approached it
- A booking form for 3 services with server-side validation of every field (name, email, weekday date from tomorrow, half-hour slots, quantity, notes).
- CSRF token and a hidden honeypot field against spam.
- SQLite storage with a unique rule on service, date and time, so a slot can only be booked once.
- Invoice numbering (INV-year-0001), 10% tax calculated in cents and a 14-day due date.
- A test script with 24 tests.
Source: my design and the sample files
05How this applies to your business
- Assess and designMap the current process, size the gaps from your own data, agree the design and a written scope.
- Build and testBuild in your own tools with the checks built in, then run real cases end to end.
- Document and hand overSOPs, a walkthrough and a handover, so your team runs it without me.
| Activity | Business owner | Specialist (me) | Your team |
|---|---|---|---|
| Approve services and prices | A | C | R |
| Build and test | I | R | I |
| Host and maintain | A | C | R |
Source: sample plan
06Controls and checks
| Check | What it catches | Status |
|---|---|---|
| Form validation tests | Bad input reaching the booking | 15 of 15 |
| Invoice tests | Wrong tax, totals or due dates | 5 of 5 |
| Slot tests | Double bookings | 3 of 3 |
| Sequence test | Duplicate invoice numbers | 1 of 1 |
Source: sample files (Checks / Controls tab, test output or run log)
07What the files show
- 24/24tests pass
- 5PHP files
- 243lines of PHP
- 0double bookings allowed
Source: sample files, measured by script. Sample data, not a client result.
- tests/run_tests.php reports 24 of 24 tests passed (output included in the download).
- Run locally with php -S and checked in a browser: invalid input, a confirmed booking and a refused second booking (screenshots below).
- Impossible dates such as 31 November are rejected.
08Risks and how the build handles them
| Risk | Mitigation built in |
|---|---|
| Spam bookings | Honeypot field and validation |
| Double booking | Database rejects a duplicate slot |
| Price tampering or forged posts | Prices are calculated on the server; CSRF token on the form |
Source: sample design
09Appendix: files
A. Screenshots of the deliverable

Exhibit 8: Booking confirmed with invoice INV-2026-0001: line, net, 10% tax and total calculated server-side
Source: sample files
public static function fromBooking(array $b, int $seq, DateTimeImmutable $issued): array
{
$svc = Validator::SERVICES[$b['service']];
$unitCents = (int)round($svc['price'] * 100);
$netCents = $unitCents * (int)$b['qty'];
$taxCents = (int)round($netCents * self::TAX_RATE);
return [
'number' => sprintf('INV-%s-%04d', $issued->format('Y'), $seq),
'issued' => $issued->format('Y-m-d'),
'due' => $issued->modify('+14 days')->format('Y-m-d'),
'customer' => $b['name'], 'email' => $b['email'],
'lines' => [[
'desc' => $svc['label'] . ' on ' . $b['date'] . ' at ' . $b['time'],
'qty' => (int)$b['qty'], 'unit' => $unitCents / 100, 'net' => $netCents / 100,
]],
'net' => $netCents / 100, 'tax' => $taxCents / 100, 'gross' => ($netCents + $taxCents) / 100,
];
}
Source: Invoice.php
B. Downloadable files
| File | What it is | Size |
|---|---|---|
| php-booking-invoice.zip | Full source: public/, src/, tests/ (run with php -S) | 396.5 KB |
| test-output.txt | Test run output | 1.2 KB |
| Validator.php | Source file | 2.5 KB |
| Invoice.php | Source file | 1.2 KB |
| Store.php | Source file | 1.5 KB |
Sample build: realistic data, built to show how I'd handle this work. Names are placeholders and no client data is used.
Have a similar problem in your business?
Hire me on Upwork (opens in a new tab)
