 Right, so hey guys and welcome back to another PHP tutorial so as said in the last video today I'll be uploading a video based on how to use validation in PHP so that the user is not able to create blank accounts or Enter really any information that shouldn't be entered in a field So first off like always what you want to do is start your Apache and SQL servers They're not going to be working with SQL today, but just in case you might as well open it I'm going to open an incognito tab and access my website Okay, so this is what we led to last time We led to a bit of designing to the login and register system that we created earlier And now as you see we have a decent looking login and register system. It does work But we just need to make sure that the validation works as well So what validation essentially should do is prevent the user from creating a blank account So right now if I click on register, it says account with this username already exists mainly because when the username and password field is left blank And if we click register if we go to our database Look a host PHP my admin Give it a quick second to load up and if we go in trial system Users If you see right here, what's what you're going to notice straight away is that We have a user with the username blank and the password blank Essentially, this shouldn't be allowed on a website So what this user could do is just click on the login button and I would say welcome admin because obviously Here we've left a blank. He was allowed to create a blank count. This would be a problem in a system So how we resolve this is by using validation So what we're going to do is go to a code from last time cancel and Then we go to the code for the register part So what's going to happen here is before anything starts We're going to gather the username and password and then we just add an if condition we say if oops if register username equals none or register password equals none What we want to do is echo a paragraph Obviously in the center of the screen and we want to say All fields required Basically, this would let the user know that he needs to fill in all the fields before the Execution can occur for the register program and then we just add an else statement which means if the obviously if the user has filled in the Fields then he should be allowed. So we just carry on here and we end it right here So we're just going to run this quickly to see if it works. We refresh Expected online 67 Okay, because we need multiple brackets. I think I'm just going to add another bracket because of the all say refresh Now if we click on register as you see it says all fields required because We haven't filled in a username or a password Now let's try filling in a username and clicking on register. It still says all fields required Now we're going to create a new account called trial one two three and click on register and as you see right here Account has been created. That's obviously because the fields were filled in So now we've got some kind of validation on the website to make sure that the user is not allowed to create a blank account If we try to log in using trial, which we just created right now, it should work We also need to do this for the login button so that the user is not allowed to log in when the Username and password fields are left blank All you need to do for this is literally copy the code which we used right here Obviously, you can't copy the end bracket. So you need to make sure you add that later and Then do this here and then add an ending bracket at the end of it else right about here So now if we refresh the page and click on login Okay, so The only change you might need to make here is instead of having regular username or we see you need to change that to the Username and password and these lines will go above Because we need to gather the username and password obviously so change the get rid of the reg and leave the username and leave the password There's the variable types of data down there. If we click on continue It's going to say all fields required But if we try to log in using just a username still it's going to say all fields required username and password login and we're in So that was it for today's tutorial guys So I was able to help you with a bit of validation being added to your website and explaining its importance You could also add different types of validation such as restricting capital letters or restricting numbers I'm not going to follow through on that in this tutorial if you would like something like that Please request it in the comment section in the next tutorial I'm going to be going ahead with a few more functions that we can add so Essentially when the user logs in into the system you should be able to carry see his dashboard and Obviously his information should be carried over instead of saying welcome admin It should say welcome his username instead of calling everyone admin Since this page is static we're going to try and make it dynamic the next tutorial. So stick around until the next tutorial Please make sure to subscribe like comment, and I'll see you in the next one. Peace out