From the course: Validating and Processing Forms with JavaScript and PHP

Unlock this course with a free trial

Join today to access over 22,400 courses taught by industry experts.

Using server-side validation

Using server-side validation

Now that we know how to access variables, let's take a look at how we would validate data in different ways. I'm going to show you how to check for a required field, a minimum number of characters, make sure that our passwords match, and use regular expressions for validation. So, I'm going to set up some variables in my process.php file. I'm using the files from the previous movie, so I'm going to go ahead and delete everything right here. And start by creating some variables. The input fields that we're going to work with are: the name field, the password field, and the password confirmation field. So I'll create variables for those. I'll check the request, that we got from the server, and look for the variable, my name, from the form. I can do the same thing for the password and the password confirmation. The easiest type of validation to do is check for required field. All you have to do is make sure that the string is not empty. So, let's do that with the name. So if the name is…

Contents