$gear_id = test_input($_POST['gear_id']); $gearObject = new Gear(); $gearObject->fetch($gear_id); //can be empty. placeholder text in form $name = test_input($_POST['name']); //can be empty. placeholder text in form $qty = test_input($_POST['qty']); //type cannot be empty. one will be filled at least. $type = test_input($_POST['type']); $newType = test_input($_POST['newType']); $newIsDisabled = test_input($_POST['disabled']); $newNotes = test_input($_POST['notes']); //------------------------ name changes ------------------------ if (!empty($name)) { //user changed name $gearObject->setName($name); $successes[] = "Renamed gear item to {$name}"; } //------------------------ qty changes ------------------------ if (!empty($qty)) { //user changed qty if (is_numeric($qty)) { $gearObject->setQty($qty); $successes[] = "Updated gear qty to {$qty}"; } else { $errors[] = "Could not set quantity to non-numeric value"; } } //------------------------ gear type changes ------------------------ //user provided a new category that doesn't exist already if (!empty($newType)) {