Decided to go ahead without VIN recording.
Copied and pasted this exact code to two other pages which populate the same database and trigger the same email from the same confirmation page.
They work perfectly.
Thank you for your help. I can resolve the issue with the first page by simply reproducing it from one of the other two.