The script works fine even if the user does not enter any data.
The next step is to make input fields required and create error messages if needed.
We tend to think of validation as something that constrains or inhibits the user; but used effectively it can help users to avoid making mistakes in the first place, and provide useful advice for correcting errors that occur.
In the database world, the logical duplication of the same data is generally considered to be undesirable.The method is similar to writing automated tests where you write a second program that checks the result of the first and raises an error if there is a discrepancy.Of course neither this method, nor N-Version programming can detect when all the versions are in error.The advantages of a layered approach to validation that includes database constraints, would seem to outweigh the disadvantages. As a database designer, I see the database as being the ultimate arbiter of the validity for data.You may well disagree with this position, but I hope I can persuade you of its virtues – or at least that you might find the discussion interesting.