Using databases adds more things that can go wrong. In this lesson, we’ll see how you can handle database errors.
We’ll talk about two new types of errors:
- Database connection errors
- SQL errors
You can check for both.
We’ll also talk about simple server-side validation. Even if you can check all data on the client, you should check it on the server as well. To foil Evil Doers.
- How to report errors in a professional way.
- How page-wide, global error messages help the user.
- How to have the HTML for the form and the PHP validation code on the same page.
- How to collect error messages in a single variable, rather than treating them all separately.
- How to write a PHP validation function.
- How to call it.
This lessons shows a complete form validation example.
- It shows good error messages.
- Some error checking is on the server side. Some is on the client side.
You know how to grab data from text fields, and do things with them. But what if the user doesn’t type anything? Or says that his or her age is -15?
In this lesson, you learn how to:
- Check whether a field has a value.
- Check whether a number is OK.
Learn how to do a sequence of checks on a value passed to a PHP page.
- Understand why you need server-side and client-side validation.
- Know how to check whether a value sent to the server is a valid number.
- How to check that data for errors.
- How to report errors to the user.