Entries tagged "form validation"

Remove White Space from Form Data to Avoid Potential Headaches

When processing form submissions, it's important to remove white space before and after each value. Those extra spaces will likely go unnoticed by most visitors, but luckily this won't be a problem most of the time. In some cases, however, those spaces can lead to a lot of confusion. [Continue reading]

Naming Your HTML Form Fields with an Associative Array

When using database entries to dynamically build HTML forms, how do you go about naming the form fields? Do you name them "Field1", "Field2′, etc.? Or do you have a more efficient way to access the fields when processing the form submissions? If you haven't tried using an array as the name, you may be missing out. [Continue reading]

Make Sure Those Passed IDs Contain Numbers

When passing row IDs between pages, it's a good idea to check the value is what you expect. Values which could be tampered with by the user need to validated and sanitized. So, if an ID is supposed to be a number, we should make sure it is before running the database query. Let's discuss some options for checking for numbers. [Continue reading]

Getting Your Projects Done Faster by Writing Less Code with the Short-hand if()

Have you coded a simple if() construct that sets a variable to one of two values and thought to yourself "Five lines of code; there should be a better way?" Okay, maybe it's just me. Either way, let's take a look at the Ternary Operator [aka the short-hand if()]. [Continue reading]