EST. 2026 — Notes from real server work SYSADMIN · SECURITY · AI · DIRECTADMIN Issue 01
THE SYSADMIN ALMANAC
Home / Web / Paper and Online Forms Drift Apart After Ten Rounds of Edits
Web

Paper and Online Forms Drift Apart After Ten Rounds of Edits

by Ton-Or ·3 Dec 2026·11 min read
Paper and Online Forms Drift Apart After Ten Rounds of Edits

When two things need to say the same thing but are written separately by hand, they always match on the first day. The trouble starts with the second edit, because the person requesting the change sees only one version, and the person making it usually edits only one version.

1-minute summary

Symptom / problem
16 quality forms exist in two drafts, paper and a mobile page, and after many handwritten revisions the two drifted apart.
Who should read
People who maintain forms in both paper and online versions.
Fix in short
Compare the two drafts word by word, fix criteria with no upper bound (12% and 40% both got grade B), and generate both drafts from a single-source definition.
Jump to steps

A small manufacturing business needed a set of quality record forms based on a list of 16 items sent by an inspector. I built two versions in one day: printable A4 paper forms and mobile entry pages that assigned grades automatically. After that, the users printed the forms, marked changes in pen, and sent photos back. I kept making those changes until the day I compared the two versions word for word and saw that they no longer said the same thing in several places. Along the way, I also found another bug caused by translating a sentence in ordinary language into code.

I have replaced the business name, organization names, equipment lists, and production processes in this article with generic examples. The number of forms, sequence of events, and threshold values at issue are real.

Two versions written separately by hand in one day

The list had 16 items. The first three were mandatory; the rest were marked as applicable. On the first day, I produced two things.

Version 1

A4 paper forms

  • 21 sheets, with a form register at the front
  • Every form had a criteria box and a field for what to do if it failed
  • Designed to be printed and filled in by hand
  • A PHP file that rendered the entire set on one page
Version 2

Mobile entry pages

  • 16 forms in 5 color groups, with a today's tasks bar
  • Stored data in a separate SQLite file and remembered the person's name per device
  • Supported photo attachments and monthly report printing
  • Assigned grades automatically from the entered values

I tested the mobile version on a phone-sized screen in both light and dark modes. For printing, I used the same approach I wrote about in dozens of document pages from HTML. Storage used PHP with a single SQLite file, as in the document storage app. Everything worked from the first day.

The mistake was how I built it. I wrote both versions separately by hand. I typed the list of 12 equipment items into one file, then typed it again into the other. The same went for production steps, criteria, frequencies, and form names. On top of that, I abbreviated many entries in the mobile version. From the very first hour, the same data existed as two copies that looked different.

16 formsBased on the inspector's list
21 -> 14Paper sheets before and after removal
6 roundsHandwritten revisions over 6 days
29 itemsSelf-assessment checklist
7 minutesHow long the attempt to share a source lasted
242 KBFull-set PDF at handover

Trying to share a source on day two, then rolling back in 7 minutes

By the next day, I could already see this problem, so I tried what seemed like the most direct fix: make the online version's print button render into the same paper templates. Entered values would fill the fields in blue. If the data exceeded the available rows, it would continue on a new sheet. Paper and online would then look the same.

Before reworking anything, I backed up both systems and the SQLite file outside the docroot. That was the only thing I got right in that round, because 7 minutes after the new version went live, the owner asked me to put it back the way it was.

# ก่อนรื้อ: สำรองทั้งสองร่างและฐานข้อมูลไว้นอก docroot
TS=$(date +%Y%m%d-%H%M)
BK="$HOME/backup/forms-$TS"
mkdir -p "$BK"
cp -a public_html/forms/paper.php public_html/forms/online.php "$BK/"
sqlite3 private/records.sqlite ".backup '$BK/records.sqlite'"

# ย้อนกลับ: คัดลอกทับ แล้วพิสูจน์ว่าเหมือน backup ทุกไบต์
cp -a "$BK/paper.php" "$BK/online.php" public_html/forms/
for f in paper.php online.php; do
  cmp -s "$BK/$f" "public_html/forms/$f" && echo "[OK] $f ตรงกับ backup" || echo "[ERR] $f ไม่ตรง"
done

# และข้อความที่เคยถูกสั่งลบ ต้องไม่กลับมากับการย้อน
grep -c 'ข้อความที่สั่งลบไปแล้ว' public_html/forms/paper.php

I did not stop the rollback at copying the files back over the current ones. I compared the files on the server with the backup to make sure they matched, then checked that text the owner had previously asked me to remove had not returned. A backup just one version older than expected can bring back things that were already deleted.

Share the definitions, not the appearance

I had misunderstood which layer needed fixing. What needed a single home was the definitions: items, criteria, frequencies, and form names. The paper layout and the mobile screen layout should differ according to what works best for each. Forcing the two versions to look the same did solve the mismatched text, but it also gave the users something they had not asked for.

6 rounds of handwritten revisions in 6 days

After that, the work followed the same cycle over and over. The actual users printed the forms, marked changes on the paper in pen, and sent photos back. I read the handwriting in the photos and edited the files accordingly, at least 6 rounds in 6 days.

The cycle that pushed the versions apartPrint formsPaper version->Mark changes in penOn paper->Send photos backRead handwriting->Edit paper filesTo match photos->Online versionNo change requested

Examples of changes made during that period

Subject Before After
Defect threshold No more than 3% About 10%
Impurity threshold No more than 1% 10%
Columns in the weekly table Included week 5 Removed
Number of forms 16 forms, 21 sheets Removed 6 crossed-out forms, leaving 10 forms on 14 sheets
Production control steps 12 items 10 items
Duration Leave overnight 24 hours
Counting unit Bags Drums
Page footer Text and sheet number Removed from every page
References to standard clause numbers Present in several forms All removed

Every change in the table was correct according to what the users wanted. The problem was that the requests arrived on paper. The person marking the changes saw only the paper, and I opened the paper file and edited it to match the photos. The online version did not receive every corresponding change in every round, and nothing warned me when I forgot, because both versions still worked normally.

What a word-for-word comparison revealed

When I seriously compared the 16 forms, I found several kinds of differences.

  • For the 12 equipment items, the online version used abbreviated names, while the paper version used full names, such as “holding tank” versus the full name of that same tank.
  • For the 12 production steps and 29 self-assessment items, the online version used abbreviated text that differed from the paper in almost every item.
  • For frequency, the paper said “Every Lot,” while the online version said “1 cycle.”
  • On the raw material receiving form, the paper version lacked the sack count and vehicle condition columns, and had no entries for glass fragments or metal, even though the online version had them.
  • Wording that had already been ordered removed from the paper remained in the online version.

The most dangerous differences were the last two, rather than the abbreviations. Different columns meant that someone recording on paper and someone entering data on a phone were collecting different sets of data for the same job.

One visual comparison was enough to wear me out, so I built a comparison tool. At that point, the definitions were still embedded in each version's file, so the actual tool first had to extract arrays from both files. The comparison itself followed this structure.

<?php
// tools/audit_sync.php — เทียบรายการของร่างกระดาษกับร่างออนไลน์
// ใช้: php tools/audit_sync.php
$paper  = require __DIR__ . '/../forms/paper_lists.php';    // ['equip' => [...], 'steps' => [...], 'freq' => [...]]
$online = require __DIR__ . '/../forms/online_lists.php';
$bad = 0;

function cmp_list(string $name, array $x, array $y): void {
    global $bad;
    $x = array_values(array_filter($x, 'strlen'));
    $y = array_values(array_filter($y, 'strlen'));
    if ($x === $y) { echo "[OK] $name (" . count($x) . ")\n"; return; }
    $bad++;
    echo "[DIFF] $name\n";
    echo "  paper only:  " . implode(' | ', array_diff($x, $y)) . "\n";
    echo "  online only: " . implode(' | ', array_diff($y, $x)) . "\n";
}

cmp_list('รายการอุปกรณ์',  $paper['equip'], $online['equip']);
cmp_list('ขั้นตอนผลิต',    $paper['steps'], $online['steps']);

// ความถี่: ทุกรหัสฟอร์มในทะเบียนกระดาษต้องมีในออนไลน์ และข้อความต้องตรงกัน
foreach ($paper['freq'] as $code => $f) {
    $o = $online['freq'][$code] ?? null;
    if ($o === null)  { $bad++; echo "[DIFF] $code ไม่มีในระบบออนไลน์\n"; continue; }
    if ($o !== $f)    { $bad++; echo "[DIFF] $code ความถี่ กระดาษ='$f' ออนไลน์='$o'\n"; continue; }
    echo "[OK] $code ความถี่ $f\n";
}
foreach (array_diff_key($online['freq'], $paper['freq']) as $code => $f) {
    $bad++; echo "[DIFF] $code มีในออนไลน์ แต่ไม่มีในทะเบียนกระดาษ\n";
}

echo $bad ? "\nพบ $bad จุดไม่ตรงกัน\n" : "\nตรงกันทั้งหมด\n";
exit($bad ? 1 : 0);

The comparison deliberately required every character to match. An abbreviation and its full text might clearly mean the same thing to a person, but the machine had to count them as a mismatch. If similar wording were allowed to pass, I would end up back where I started. Alongside that, I had scripts to generate each version's files from source files, and a browser check to ensure the content did not overflow the sheets.

A threshold with no ceiling: 12% and 40% both get grade B

Another bug came from a single handwritten sentence. In the round where the defect threshold changed to about 10%, a note said that slightly over 10% should receive grade B: accept it, reduce the price, and sieve it before use. I translated that sentence directly into code.

// รุ่นที่ผิด: แปล "เกิน 10% เล็กน้อย = B" เป็นเงื่อนไขเดียว
function grade_old(array $d): string {
    foreach (['mold', 'insect', 'hazard'] as $k) if (($d[$k] ?? '') === 'พบ') return 'C';
    if (($d['sack'] ?? '') === 'ไม่ผ่าน') return 'C';
    $m = $d['moist'] ?? ''; $b = $d['badp'] ?? ''; $f = $d['forp'] ?? '';
    if ($m !== '' && (float)$m > 13) return 'C';
    if (($b !== '' && (float)$b > 10) || ($f !== '' && (float)$f > 10)) return 'B';   // ไม่มีเพดาน
    return 'A';
}

The word “slightly” disappeared along the way. The writer had a limit in mind, but the code knew only “greater than 10.” A defect rate of 12% got B, and 40% got B as well. Grade C could occur only if mold, insects, or hazardous fragments were found, moisture exceeded 13%, or the sacks failed inspection. For raw materials that were almost half defective but had nothing else wrong, the system would recommend accepting them at a reduced price.

Shared form definitionsItems, limits, frequency, nameA4 paper rendererPrint: 10 forms, 14 sheetsMobile rendererPHP + SQLite auto-gradingBefore: over 10 = B, no ceilingAB extends without limit12% gets B40% also gets BAfter: A up to 10 / B up to 15 / C over 15ABC Reject, return to seller12% gets B16, 18, 40% get C0101540Defects or impurities (%)
Top: form definitions should live in one place for two renderers to read. Bottom: the original criterion became code saying over 10 = B, so the B range had no end, and 12% and 40% received the same grade. Adding a ceiling of 15 reduced the B range to just 10-15.

I provisionally set the ceiling at 15% to close the gap, then asked the user how far “slightly” extended. The answer was “15, return,” meaning anything over 15% should be returned to the seller. The corrected code therefore had three clear ranges: A up to 10, B up to 15, and C above 15.

// รุ่นที่ใช้: ทุกเกรดมีทั้งขอบล่างและขอบบน
function grade01(array $d): string {
    foreach (['mold', 'insect', 'hazard'] as $k) if (($d[$k] ?? '') === 'พบ') return 'C';
    if (($d['sack'] ?? '') === 'ไม่ผ่าน') return 'C';
    $m = $d['moist'] ?? ''; $b = $d['badp'] ?? ''; $f = $d['forp'] ?? '';
    if ($m !== '' && (float)$m > 13) return 'C';
    if (($b !== '' && (float)$b > 15) || ($f !== '' && (float)$f > 15)) return 'C';
    if (($b !== '' && (float)$b > 10) || ($f !== '' && (float)$f > 10)) return 'B';
    return 'A';
}

Entering 16 and 18 gave C in both cases, as it should.

There was another layer of risk here. The same rules were written in two places. The server used PHP as shown above, while the screen used JavaScript to calculate immediately during entry, then displayed a box saying “System recommendation: B” with a reason such as “Defects 12 % (10-15),” and automatically selected the grade until the user made a selection manually.

// ฝั่งจอ: กติกาเดียวกับ PHP เขียนซ้ำอีกรอบ — จุดที่เพี้ยนกันได้อีกคู่หนึ่ง
var gTouched = false;                       // ผู้ใช้แตะเลือกเกรดเองแล้วหรือยัง
function grade() {
  var r = 'A', why = [];
  var b = val('badp'), f = val('forp');
  if (b !== '' && +b > 15)      { r = 'C'; why.push('ของเสีย ' + b + ' % เกิน 15'); }
  else if (b !== '' && +b > 10) { if (r === 'A') r = 'B'; why.push('ของเสีย ' + b + ' % (10-15)'); }
  if (f !== '' && +f > 15)      { r = 'C'; why.push('สิ่งเจือปน ' + f + ' % เกิน 15'); }
  else if (f !== '' && +f > 10) { if (r === 'A') r = 'B'; why.push('สิ่งเจือปน ' + f + ' % (10-15)'); }
  showSuggestion(r, why);                   // กล่อง "ระบบแนะนำ: ..."
  if (!gTouched) checkGradeRadio(r);        // ติ๊กให้ จนกว่าผู้ใช้จะเลือกเอง
}

When I fixed the ceiling, I had to change both places. If I changed only one, the screen would recommend one grade while the server saved another. It was the same mismatch problem as the paper and online forms, reduced to the scale of a single form.

These thresholds belong to one business

The values 10, 13, and 15 in this article are raw material acceptance criteria set by the person responsible at that business for their own raw materials. They are not standard values that can be applied elsewhere. Food safety criteria for actual operations must be set by qualified quality control personnel and the relevant inspectors. The programmer's job is to make the code match those criteria across every range, including asking for clarification when the supplied criteria have no upper bound.

Words that always need clarification before becoming code

Slightly, approximately, moderately, as appropriate, not much: these words can appear in criteria written for people because readers use their judgment to supply the boundaries. In code, an unwritten boundary becomes no boundary at all. Every range condition needs numbers at both ends before implementation. If only one end is supplied, put a safe value in place first and then ask, rather than leaving it open while asking.

The single source of definitions I should have had from day one

At handover, the working system still consisted of two versions in two files, with a comparison tool catching differences. That was enough for a job of this size. But if I started again, I would use this structure from the first hour: one definition file read by two renderers, one producing paper and the other producing mobile screens.

<?php
// forms/defs.php — นิยามของทุกฟอร์มอยู่ที่นี่ที่เดียว
return [
    'fm01' => [
        'code'   => 'FM-01',
        'title'  => 'บันทึกการรับวัตถุดิบ',
        'freq'   => 'ทุก Lot',
        'cols'   => ['วันที่', 'ผู้ขาย', 'จำนวนกระสอบ', 'สภาพรถ', 'ความชื้น %', 'ของเสีย %', 'สิ่งเจือปน %', 'เกรด'],
        'limits' => ['moist_max' => 13, 'a_max' => 10, 'b_max' => 15],
        'reject' => ['mold' => 'พบรา/กลิ่นผิดปกติ', 'insect' => 'พบแมลงมีชีวิต', 'hazard' => 'พบเศษแก้ว/โลหะ/พลาสติก'],
    ],
    // ... ฟอร์มอื่น ๆ ...
];
<?php
// ตัว render ทั้งสองอ่านนิยามชุดเดียวกัน หน้าตาต่างกันได้เต็มที่
$defs = require __DIR__ . '/forms/defs.php';

function grade(array $d, array $lim): string {
    foreach (['mold', 'insect', 'hazard'] as $k) if (($d[$k] ?? '') === 'พบ') return 'C';
    if (($d['sack'] ?? '') === 'ไม่ผ่าน') return 'C';
    if (($d['moist'] ?? '') !== '' && (float)$d['moist'] > $lim['moist_max']) return 'C';
    $worst = max((float)($d['badp'] ?? 0), (float)($d['forp'] ?? 0));
    if ($worst > $lim['b_max']) return 'C';
    if ($worst > $lim['a_max']) return 'B';
    return 'A';
}

// ฝั่งจอไม่เขียนตัวเลขเกณฑ์เอง รับจากนิยามเดียวกัน
echo '<script>var LIM = ' . json_encode($defs['fm01']['limits']) . ';</script>';

The paper criteria box would also print from the same limits. Changing the ceiling from 15 to another value in one place would update the paper, screen, and grading together. For text that needed to be shorter on mobile, I would add a short-name key to the same definition instead of typing it again in another file.

Form codes that do not run 7-8-9, and the handover deliverables

After removing 6 forms, the remaining codes were 01 through 06, then 11, 12, 14, and 16. The owner asked why I did not renumber them to continue with 7, 8, and 9. I kept the original numbers because the form codes matched the item numbers in the inspector's list. If I renumbered them, our form 07 would no longer be their item 7. Every request for a document by item number would need a mapping table in between. To meet the need for consecutive numbering, I added a separate sequence column from 1 to 10 in the register. Codes are for references shared with outsiders; sequence numbers are for counting what is on hand. They should not be the same number.

For handover, I added links between the two versions on every form. From any paper form, users could go to the online entry page for that same form, and vice versa. I also provided PDFs in three formats: the full set at 242 KB, individual sheets, and individual forms. Those links also helped with mismatches indirectly, because anyone could open the two versions for comparison with a single click.

What I will carry into the next job

  1. Before typing any text into a second file, stop and move it into a definition file so both versions read from the same place.
  2. If two copies must exist for a while, use a comparison tool that requires every character to match, and run it after every edit.
  3. Treat a change request from either version as a request to change the definition, then check the other version immediately.
  4. Range criteria need numbers at both ends. Ask for numerical clarification of words such as slightly or approximately.
  5. For rules calculated on both the server and the screen, supply the threshold values from one place instead of writing them twice.
  6. Back up files and the database outside the docroot before reworking anything. During rollback, compare against the backup and check that previously deleted content has not returned.
  7. Do not renumber codes used for external references. If consecutive numbering is needed, add a separate sequence column.

The two versions drifted apart because there were two places to edit from the start, not because anyone made an incorrect change. Every edit was correct in the version where it was made. Personally, I would rather spend more time on the first day building a definition file than compare 16 forms word for word later. Anyone working on something smaller is welcome to keep two files and use a comparison tool to keep them in check. Just do not use human eyes as the comparison tool. If I have missed anything in the explanation or made a typo, I will come back and correct it later.

Want us to set this up?

Get help with server setup, configuration, migration, or troubleshooting. Save time for the work that matters.

Get a quote

Hit something like this? Stuck somewhere?

Come trade notes on the LinuxThai board

→ Continue on the board

Comments 0

No comments yet — be the first