How To Create A Login System In PHP For Beginners | Procedural MySQLi | PHP Tutorial

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
how's it going everyone and welcome to my third video on how to make a login system yes i'm quite aware this is the third time we're making this video but i have a good reason to so on my channel right now i have a bunch of different project videos you know based on php or other sort of programming languages but none of them are actually connected to one another so my idea is to redo my login system video so i actually have a good fundamental base in order to expand into other different types of projects like for example a profile system or something to a website so recreating the login system in a much better way that is much better suited to actually continue building on it is something i thought was quite necessary to do just very quickly before we get started here because i'm actually recording this after having made this whole episode and recorded and everything this episode will be quite lengthy so just be prepared that this is going to be a long video i promise you at the end of it you will have a login system it's going to be you know i'll try to explain everything as simply as i can to make sure that i'm not just saying you know write this then write this and then you don't have any clue about what is being said in this video i will explain everything to sort of make you understand what we're doing and why we're doing it so please bear in mind that this is going to be a lengthy video but it's going to be very good hopefully i hope you enjoy it at least now the first thing i just sort of want to talk about is address the lesson file material you will be able to find everything in this video on my patreon or if patreon at some point in the future gets replaced by something else then i will have a link for that including css and the html and the php and everything has been used in this video here i should point out that the reason that everything including the css is inside my lesson material is because people have voted on my channel not to have css included into my php tutorials because it takes up i think a third of the time when i also have to explain php and css at the same time so just to make this a little bit shorter a little bit smoother because you should know html and css by now so these things aren't something i should be teaching you in this video we will just be focusing primarily on the html and the php if you have any questions about the lesson material and why you have to go get it on patreon just go and read the description of the video or the pinned comments below in the comment section so let's talk about the actual login system what exactly are you going to be learning in this video here because you know there's a lot of ways you can do different systems using php my goal for this video is to make it into the easiest to understand login system tutorial that you might find on youtube or any other place on the internet for people has never done anything when it comes to creating a php system of some sort so if you're completely new at php and this might be your first project or maybe you have had a couple of projects before but you're still quite new at php this is going to help you out tremendously when it comes to understanding how a login system functions i should point out that this is by no means a login system that is fully fleshed out with all the different security messages that needs to be taken with php if i were to talk about everything regarding security when it comes to php we're gonna have a much longer tutorial going so this is going to cover the basics of how to create a login system so you can take this login system and apply it to your website and once you learn about any other sorts of security measures that can be taken on your website just go and include it into this project here it's very easy for you to customize what we're making in this video here that being said the one thing that we will be focusing on in this video is going to be to use prepared statements which is a way for us to sort of protect the data that we get from users and put into our database you know so it so the user doesn't really you know inject any sort of dangerous stuff into the database so we will be using prepared statements in this video here another thing i want to mention as well is that this is a procedural php project i know a lot of people are asking for object oriented php i will at some point get to that in the future but for now this is for my you know people who just started with php and wants to learn how to do this sort of thing so it is going to be procedurally generated php that we're going to be making in this video here i think the title will say procedural php as well so if you clicked into this video and you're complaining it's not object oriented php you should have read the title before clicking the video and finally before we get into it you will most likely encounter errors along the way which is something that i usually just see people do when they ask me questions in the comment section i will have a list of errors inside the description of this video here you know with the name of the arrow you might have and then what are the possible fixes and why are you getting this error so if i encounter people having errors i will try to list them inside the description one by one just so you kind of have an idea about okay so i'm getting like undefined something online something what does that mean well it will tell you in the description of this video here so before we get into actually making this website here let me actually just demonstrate what exactly we're going to be building this episode just so you don't you know follow along and then at the end you see what we're actually building you're like oh that's disappointing i didn't know that going into this video here so let's just talk about what exactly it is we are going to be making once we're done with this episode here as you can see i have a very basic website here and the reason it doesn't look very fancy it's because i know that css or making something that looks visually very complicated can sometimes confuse people who are new to php so i tried to keep it as simple as possible not to confuse people for some odd reason some people who follow my tutorials in my php series has an idea that the php code that we're doing is not gonna work if the css doesn't look the exact same way on their website as it does in my website just remember the css of a website is only visuals it's not about how the actual website functions and because this is a login system tutorial how the website looks like should not have any impacts on what we're doing this episode so you can customize the website in any sort of way using css is not gonna matter your website should not necessarily look like my website okay just create something using css for yourself um like i said it's not an html or css tutorial this is a php tutorial oh gosh daniel why do you have to say that so many times well it's because i get a lot of questions about it every single time even though i said in the video i will still get comments about it the lesson material on my patreon page is in case you can't do something using php or it might get an error maybe you need to compare my code to yours it's on patreon then so i have this basic website here and i just created some you know some different pages here just out of fun we're not really going to do anything with most of these things uh what we will be doing is we'll have the home page we're going to have a sign up page and a login page the content down here is not something we're going to use for anything because like i said it's just placeholder it's just so you have an idea about us actually having a website here in this little project that we're doing um this is not gonna do anything in terms of our php it's just basic junk that i inserted just to to make it look good so what i'm going to do is i'm going to go into my sign up form and what you can do in here is you can type in you know different things to sign a person up you can type in the full name of the person the email username password repeat the password click sign up somebody's going to get signed up into the website and once you're signed up you can go into the login page type something in i have a very weak password here that's something you should probably not do and once i click sign up you can see that oh suddenly we have the profile page and we have a lockout button instead of having the signup and the login form so if we click profile page you can see we don't actually have a profile page yet but it's something that we're going to be having in the next tutorial where we're going to learn how to build a profile page using php code right now we're going to build this login system here but i can promise you you can actually see that we are logged in because the website is registering that we're locked in by the fact that we have the profile page and the logout button showing if we were to click log out we get back to sign up and log in so you know we do get logged in to the website and like i said in the next video we're gonna talk about how to actually make changes to the website once you're logged in you know how can you put certain type of content into the website when one type of user is logged in and how can we change the content to fit a second user if that person is logged in like that's the sort of thing we're going to do in the next episode so just to kind of show what you should be having so far just so you know where you need to start in order to catch up to this tutorial here right now i have a basic root folder with an index page inside of it this is my index page you're going to see a lot of stuff inside my page here but this is just html we don't need to have the exact same thing this is just like i said junk so you have something to see inside the browser inside my index page i don't have all the basics covered regarding html you know all the meta tags aren't there certain things are missing but this is just like bare bone just to show you exactly how we can get started doing something using php inside my head tag you can see we just have some very basic stuff i link to a basic font on the internet because i like using special fonts you don't have to do this and i link to a style sheet which is a reset style sheet inside my css folder inside my root folder so i have a couple of things in here already i have a reset page which you should know about by now this is something to reset the styling in all the different browsers you might enter that's good to have and then i also have my own style sheet that is going to simply allow me to style my website that's all i'm doing here inside the head tag if you're already confused at this point please go watch my html and css course because you might have skipped a little bit ahead of where you should be like php is usually something you learn after html and css just to kind of mention it if we go down a little bit you can see that we have a basic navigation i have a wrapper inside my navigation just to sort of wrap everything inside my header and inside the wrap you can see we have a basic link to an image just a basic logo that i have inside my website and underneath the logo i just simply have just a basic menu just some basic menu items like a link to the front page a link to a discover page which you know again just junk i filled in to have something but the two important things you should have in here is the sign up page and the login page so these two different links inside your menu you should have inside your navigation if i scroll down a little bit you can see we have another wrapper this is going to be the one that contains all the main content of the page so inside my index page you can see that i just created a basic section that has an introduction so this is a introduction here is an important paragraph blah blah blah again junk below i also just included a second section with just basic categories like again just to sort of show you basic categories here so there's something to show inside the website and at the very bottom here you can see we have a basic footer so i end off my wrapper for all the main content for the website i have my ending body tag and my ending html tag and then i included a basic javascript page or basic javascript document into my website which just has one simple purpose which i'll just show you here and that purpose is just simply to when i click around these pages here you can see that my link up here at the top changes color based on the page that i'm inside of so as you can see it just changes to blue whenever i click around on the website again just junk that you don't have to have inside your website if you want to learn how to change the navigation buttons into different colors based on the page you're on i'll make a separate tutorial for that because this is not anything to do with creating a login system this is just bonus stuff that i created to just have a cool example to show you guys so in reality all you should have is just a basic html document with just basic meta tags and a link to a style sheet and just have a navigation inside the website you don't even have to have content inside your example you just need to have this navigation with a basic you know list of links that we can click on and then inside my root folder you can see i put all my css files inside a css folder i also went ahead and created a image folder just because i am actually using a logo inside my navigation here so i just had a picture inside my image folder for that and then i have a javascript folder just to include any sort of javascript that i might be using in a website again this is something that you should not be having in your example unless you want to do it yourself this is not important to creating a login system the only thing you should be having is a css folder with a reset style sheet and your own style sheet and an index page that's what you should have right now but daniel why are you not doing all of this step by step and actually creating the html file from scratch that we can follow well again that's because you should already know how to do this by now this is me throwing shades at you one at a time telling you oh you should have you should be at this point by now you know you can't follow this tutorial if you don't have all this stuff already and you don't know what this means so yeah so now that you're at the same point as me because you've probably spent some time pausing the video and creating all this stuff so you could follow um the first thing we're going to do is we're going to go ahead and do a thing that you should just get in the habit of doing every single time you make a website that has psp inside of it which is we're going to be dividing up the top part of the website which means the header and the navigation everything i'm just going to show you everything that is up here you know the whole black bar at the top here with the links inside of it that's something that's going to be on every single page inside the website meaning that i'm going to take this content put it inside a separate document and link to it inside my pages inside my website which means that if i were to go inside my signup page it's only this content down here inside the white box that changes the header up here is the exact same file on every single page which makes a lot easier when it comes to changing navigation changing the logo you just have to change it in one file and it'll change the whole website so inside our document here what we're going to be doing is i'm going to go inside my main project root folder i'm going to create a new file i'm going to go ahead and call this one header dot php inside my header.php i'm just going to go ahead and grab everything that is going to be inside the head of the website so if i scroll down a little bit you can see that this wrapper here starts the main content inside whatever is going to be different of every single page inside the website so right below my navigation i'm going to grab this wrapper here and copy all the way up to the top copy it delete it go inside my header.php file paste it in and save it then i'm going to go back inside my index file and at the very top here i'm going to go and open up my php tags and i'm just simply going to go ahead and link or include this header.php inside my index file so i'm going to say include underscore once single quotes i'm going to go and say header.php and if it were to go and refresh the website you'll notice that it is the exact same as before because now there's no visual difference because we didn't break the website i'm still inside my index page but in this case here we're just linking to the content at the very top here which is just a much better way to do things and you guessed it we're gonna do the same thing when it comes to the footer so we're gonna scroll down we're gonna grab the footer i'm gonna grab the closing of the wrapper tag that wraps all the main content of the website copy it delete it save go up and actually create a new file call it footer the php and just paste everything in then i'm going to go inside my index file i'm gonna copy the include that we have at the top here just the whole php tag gonna go to the bottom again paste it in and just simply change the link to it so now it doesn't say header it says footer the php and everything should be the exact same way because we didn't actually change anything except for the way that the files are linked together so now we have this index page we're actually completely done doing anything else to this index page i'm not really going to use it for any other sort of purpose in this video so we're just gonna go ahead and leave this index page for now i'm gonna start moving on to the next step the next step on our website includes actually making a login page and a sign up page because right now we do not have anything that the user can click on and go into our website and sign up inside our website so that's what we're gonna do right now so inside my project file here i'm just gonna right click on my root folder i'm gonna say want to create a new file i'm just simply gonna call this one sign up dot php and just go ahead and copy paste everything inside my index page copy it and paste it inside my sign up page now inside my sign up page we of course need to change the content so i'm just going to go and delete you know the main content of this page here and do you remember we're still linking to the header we're also still linking to the footer let's just go and move this over a little bit and what we're going to do is just simply going to change whatever is inside this section here now my case here i do actually have some css that is set up for my particular signup forms i'm just going to go ahead and change this here so it says sign up i'm just going to say form and inside the actual content let's just go and delete what we have here because we don't need to have a intro paragraph or header so what i'll do here is i'll go ahead and create a h2 tag and inside the h2 tag we're just simply going to call this one sign up spelling mistake then below the h2 tag we're going to create a basic html form because in case you don't know the main way that we communicate with users inside a website is by having them fill out something inside a form and when they submit the form we do something with the data from the form that's the primary way we interact with users when it comes to them giving us any sort of input so inside this form here i'm just going to go ahead and delete the class because we don't actually need that just you know we just need basic html and i'm going to go and change the action that i have in here so the action is going to be the page that we're getting sent to when the form is submitted so what we do is we take all the inputs from this form and we put it inside the url and pass it on to the next page inside the url that's how we pass data from one document or one page inside our website to another so i'm going to go ahead and say that the action is going to be a sign up dot inc dot php and now you might be very confused because why did i just call it signup.inc the php the dot inc inside the name is just simply a very creative way for me to say that this is a include file this doesn't change the actual format of this document here it's just basic and name so it i could also if i wanted to have called it signup dash inc the php or something so in the future if you have any questions about why i might name my file dot inc or why i might not include dot inc if i don't put dot inc inside my files it means that the file is actually a page that the user is seeing inside the website if there is a dot ink inside the file name it means that the user is not actually seeing the file it just has a basic php script that runs inside of it and in this case here i think it makes sense that because this is what is going to be handling the sign up part of the website when the user needs to get signed up inside the website it makes sense to call it signup.inc.php now the thing is here though that i'm not going to put this file inside the main directory of my root folder so what i'll do is i'll click on my or right click on my folder and i'll go and say i want to create a new folder and i'm going to call this one includes so inside my includes folder is going to be where i'm going to save and create this new file called signup.inc.php so i'll right click on it and i'll say i want to create a new file and i'm going to call this one signup.inc which again stands for includes dot php i'm going to go back to my regular signup page and inside here we're just going to go and continue creating this form here now in this case with the method inside our form attribute we're just going to go ahead and keep it at post because we don't want the actual data to be visible inside the top of the url it's still going to get passed on to the next page but we won't be able to see it inside the url and that's important because we do actually have some sensitive data here like a password don't want to show that to anyone so i will be keeping the post method here inside the form we're gonna have a whole bunch of inputs that the user can type something into you know one for the full name one for the password one for the email you know different sort of things so what i'll do here is i'll just go and create a input html tag and i'll set the type as text the name is going to be something that we use once we do actually want to do something with this data using php so this is a very important attribute so in this case here because this is going to be the full name the user is going to type in i'm just going to go ahead and call this one name now the value is going to get replaced by placeholder if you don't know what placeholder does i do recommend just sort of looking up on google or something or i can just explain it very quickly the placeholder just simply writes a little you know transparent sort of text inside the input that tells the user okay what are you supposed to type into this input here in this case here i'm going to tell it that this is going to be full name dot dot so the user knows what they're supposed to type in and then i'm just gonna go and copy this and paste it down one two three four four times in the second one i'm gonna change it into email because i want the user to submit an email as well then i want to change full name to email because that makes sense then i want to change the next one into uid because this is going to be the username that the user is sending to us because they need to have a username on the website so i'll just go ahead and say username inside the placeholder the next one is going to be a password so i'm going to call this one pwd inside the name i'm also going to change the type into password and what this does is that when the user starts typing something into this input inside the website it won't actually type out the letters like the actual word that the user is typing into the input it's just going to show us like little star symbols so if there's a person standing behind the person while he's making his password they can't look over his shoulder and see what he's typing in so that is what we're going to go and include in here i'm going to go ahead and include that inside the bottom one as well because this is going to be a pwd repeat because this is a repeated password then we're going to change the placeholders for these two so password and then repeat password like so the last thing we're going to include inside this form is just going to be a basic button so i'm going to say button which is going to be a type as submit and inside the name i'm just simply going to give it a name as submit and this is going to make sense once we get to the php part so just create a name equal to submit for now inside the button i'm just going to say sign up save it and that's basically what we need to have inside the sign up page a little bit later in this tutorial here we will actually need to do something below here under the sign up page where we do actually include error messages in case the user i don't know types in a username that already exists inside the database or if the user didn't fill in all fields you know that type of thing then we will be able to include error messages down here for now let's just go ahead and do that a little bit later let's not worry about it right now so with this let's actually go and see what we have inside our website so we have refresh go to sign up you can see that right now we just have a very basic sign up page now just for the sake of my own html and css styling because as you can see the the form is just sort of slide over to the side i'm just gonna go ahead and add a little bit of styling to my my website here just something that i personally do because this is something that i included inside my css so you don't have to have this this is just something for me personally so it looks somewhat nice so if i save this you can go ahead and see that now it looks like this is again basic junk styling that i just include inside my website here so the next thing we need to do is we're going to create the login page because if we click on it you can see oh oh there's no file called login.php inside our website so let's go and go back inside our document here and what i'm going to do is i'm going to right click on my root folder i'm going to say new file i'm going to call this one login dot php i'm just going to go and copy everything that i have inside my signup.php file which is right here copy everything paste it inside my login.php so we have the exact same thing in there and i'm just going to change a few details here so instead of it saying sign up i just wanted to say login i think that is that two words we'll just go and put in two words for now now we do need to change a few things here so we need to change the action inside the form because when we log into the website we don't want to run the same php script as when we sign up inside the website so what i'll do here is i'll say login dot inc the php instead which also means that i need to go inside my includes folder right click make a new file call this one login dot inc dot php which is just going to be containing the basic php script that is going to lock in the user inside this website here then back inside our login.php file we're just going to go ahead and delete a bunch of different inputs we don't need to have two of these different inputs just the regular ones we do need to have a password one and we do need to have a button so we just have two inputs and a button for now inside the first input i do want the user to type in either their email or the username because i want them to be able to use both of these if they want to use either one when they want to log into the website because i get people asking me about how to do that so we might as well just do it in this episode here so i'm going to type username forward slash email just so they have an option of either one when it comes to signing up below here we just want them to type in the password so this doesn't need to be changed in any sort of way and we also need to change the text inside the button here so it needs to say log in like so and just like inside the sign up the php file at some point a little bit later in this tutorial we will be making some error handlers below here so if the user is making an error like not typing something into one of the inputs we can actually write an error message below here we're not going to do that right now though so now we actually basically have the entire website made when it comes to html and css and the next part is going to be actually creating the php part so we're going to connect to the database and we're going to go ahead and make sure that the user can actually go to our website click the login page or the sign up page write something in submit it and either sign up or log into our website so the first thing i want to do here is i want to go ahead and go inside my includes folder right click create a new file and i'm going to go and call this one dbh dot inc dot php and dba stands for database handler which means that this is going to be the file that handles actually connecting to the database so we can then later on when we need to connect to any sort of data inside the database or pull out data or insert data or something then we just simply refer to a variable inside this file in order to get a connection going to the database so this is going to be a very important file just to simply connect to our database inside this file i'm just going to go ahead and open up my php tags now i'm not going to go and close off my php tags and this is a question that i also get quite often if i were to close off my php tag whoops that's actually doing probably like so and we're to have some php code inside of here and then later on by accident leaving a couple different empty lines underneath my closing tag this can actually throw a error or do something wrong inside the website this is something that can actually go ahead and do something bad also if you were to actually type something or go ahead and click space or going to just you know do something it's going to end up bad so a small trick here when you have any sort of document that only contains php code like this document is going to do just go ahead and don't have a closing tag for the php opening and closing tag just just open up the php and then just leave it open so inside of here in order to connect to the database we need to give it a little bit of information about our database such as what is the you know the server name what is the username the password what is the database name of the database they want to connect to so in this case here what i'm going to do is i'm going to create a variable i'm just going to call this one server name then i'm going to go ahead and set it equal to double quotes semicolon just going to go ahead and copy this down three more times and just change the names of them the second one we're going to go ahead and set to our database username so db username we're also going to change the third one to db password and the last one down here is going to be just a database name so db name in my example here i'm using xampp at the moment in order to connect to my database and connect to my server and everything here so in my example here i need to type in localhost because i'm using a local database using xampp and i also need to go and include a username which is going to be root the password is by default when using xampp empty so we're not going to do anything in there and then the database name depends on what i call my database inside my php my admin which is the place where we create databases and tables and all that different data is going to get thrown in there we haven't done that yet so you know just we'll do that in a second but for now let's just go ahead and give our database some sort of name so we're going to go ahead and call this one i don't know php project 1 or something because that's what i called it inside my notes here just know you can call this anything you want you can call this login system or something you know if you want to change the name of it below here we're going to go ahead and create a variable called variable con which is going to be the connection that is actually going to you know open up a connection to our database so we can actually do something with the database in this tutorial here we're going to be using mysqli i should probably also write that in the title so people don't get confused a lot of people ask about pdo it's very important to note here that mysqli is something used for procedural php pdo or mysqli is something you can use for object oriented php so because this is a procedural php tutorial the option that we have is mysqli okay i often get people asking me why you're not using pdo because that's just so much better or something and i just want to point out for that argument for optic going to php pdo has some good things about it and some bad things about it mysqli has good things about it bad things about it it's about which purpose or what exactly you're making that might make you want to choose one or the other it's not that one is just like definitely better than the other one in all situations it's very much about what exactly you're sitting here doing but like i said we're doing a procedural php project right now so we only want to focus on mysqli to that i also have another thing just to really quickly add because i will get people asking this in the comments no we are not using mysql functions inside our code right now we're using mysqli mysqli is the updated version that replaced mysql many years ago well many years ago some years ago because mysql is not secure okay mysqli is very much up to date this is not mysql just want to point that out because some people are like raging in the comments saying why using mysql to you know do stuff with your database that is not secure that is outdated you should know that by now daniel and to that like i said we're using i so right after the equal sign i'm just going to go ahead and create a mysql i function underscore connect parentheses and inside this function here which is a built-in function inside php we're just simply going to drag and drop these different variables we've created up here that this particular function needs in order to give it what it needs in order to connect to our database so we're going to give it the server name going to give it the username i'm also going to give it the password and last but not least we're going to give it the database name for the database that we're connecting to then below here we're also just going to create a very quick if statement that is going to just let us know if there's any sort of errors happening with the connection so i'm just going to go ahead and say that inside here we want to say if our connection fails by saying variable con and then putting a exclamation mark in front of it which means that if this returns as false then we do want to write out some sort of error message or something first of all we want to just kill off whatever we're doing here by writing die and we also want to spit out a message on the browser that says okay what exactly is going wrong here so i'm just going to say connection failed colon and then we're just simply going to add in some another php function called my sqli underscore connect underscore error which is going to spit out the specific error that we're encountering inside if you were to actually get an error message and this is basically all we need to do here so now the next step is that we did actually include a database name inside our database variable up here but we haven't actually created the database that we're going to put all the data from our website into so what we're going to do is i'm going to go and open up my browser i'm going to write localhost forward slash php my admin that should be and again this is something that sometimes happens when you want to write stuff in on google i'm not searching for phpmyadmin i actually want to access phpmyadmin and there we go so localhost forward slash phpmyadmin and now we have our database or at least the place that we create databases inside our browser here um this particular database setup system with phpmyadmin is the most common thing you'll see with hosting companies around the world when you want to you know rent a server by some sort of hosting company and you need to go in and need to copy your database from your local version of your website into the online version of the website this is going to be what most people are using just to point that out so inside phpmyadmin i'm going to go to databases and over here you want to type in the name of your project so in this case here i wrote that it was going to be phpproject01 and just go and create it now i do already have mine created over here as you can see i do already have some data inside of it i have a user's table you shouldn't have that yet but by now you should actually have your php project 01 on the left side over here so you can actually see your database this is something you should know by now but all these different things here are actually databases that you've created inside your phpmyadmin some of them will be in here from this start once you install this program for the first time as you can see i do have some other stuff in here that i didn't actually create but you should know that this is your database sitting over here the next thing we're gonna do to our website so we can actually continue building our login system is we're gonna go ahead and create the users table inside our database as you can see i already have mine here but i will actually go ahead and show you exactly what you're going to do in order to create a uses table so what you're going to do is you're going to go ahead and click on your database over here you want to make sure that you have this database selected once you've done that we're going to go up into the sql tab up here at the top and then we're going to go ahead and type in the sql that we're going to actually insert into our website here let me just go ahead and zoom in for you is that good enough can you actually see what i'm writing here okay so what i want to do is i want to go and create a new table and i want to call this one users i'm going to say parentheses semicolon and i'm just going to go and move the parentheses and the semicolon down to the next line so we're actually you know creating a little bit of space or some lines in between here and now what we're going to do is we're going to go ahead and create some columns inside this users table so in case you don't know the users table is going to contain all the data that we want to collect regarding users inside our website in this case here i just want to know about the user's name like what is the name of the person i want to know what their email address is i want to know what their username is going to be and i also want to know the password they selected in order to log into this website here so the first column that i'm going to create inside this table here is going to be the user id and yes you are correct i didn't mention the user id two seconds ago when i mentioned all the different data we're going to save from the user because the user id is something that's going to auto generate as users are signing up one by one so what i'll do here is i'll go ahead and call this one users because that's the name of the table so just a naming convention is to call it the name of the table and then what the column is going to be named so users i d now i should mention that the user's id like i said auto generates and creates a new number one at a time so when the first user on your website signs up this one is going to be called one then when the second user signs up to your website he's gonna be user number two and it's just gonna keep counting up automatically when users signing up inside your website and one question that i get constantly is okay so let's say you have 10 users inside your website and one user decides oh you know what i don't want to be part of this website anymore just go ahead and delete my account so what is going to happen is let's say user number three decided that he's not going to be part of this website anymore so he gets deleted from the database you will have an empty slot so you're gonna have user one user two user four user five and so on but you're not gonna have a user three inside your website the thing that people are asking is okay how do i make sure that the next user designs up inside the website gets the username as user number three because there's going to be this weird hole or this weird gap in numbers when it comes to the user ids that will exist inside your database column the reason you should not worry about there being a gap inside your data is because these user ids are unique to the users that are assigned to them you should see these ids that are assigned to the user as your social security number if a person in real life were to go and pass away you don't start moving every single citizen in the country and give them a new social security number because oh it makes more sense in the in the system like that's just going to confuse the heck out of every single citizen inside the country so in the same way here if a user were to not want to be part of this website anymore and were to just go ahead and you know delete his account then you just need to be okay with the fact that there's gonna be an empty slot for user number three there's nothing you should do about it if you were to try and forcefully do something about it and go into the database and manually start changing the numbers so they actually have no gap between them you're going to mess up the entire database structure don't do it so now that we got that cleared out let's go and talk about the next thing i'm going to write for this column here so the next thing we need to write is what sort of data we're going to have in here we're just going to have numbers so i'm just gonna write int 11. we're not saying that there can be 11 users we're saying that you know 11 i don't know numbers after each other that's like you know the maximum number capacity which is like a lot of users inside your website so don't ask too many questions about this 11 should be plenty of users for your website so with this we're just going to go and continue the next thing we're going to write is that this is going to be the primary key of this particular table here which means that this is going to be the unique identifier of every single user inside this particular table here remember when i talked about social security number that's basically what we're labeling this particular column as the next thing we're going to add in is o2 underscore increments and the reason we want to add this in is because now it's automatically going to increase each user by one automatically every single time the user signs up so you don't have to worry about it yourself and then we also want to add not null at the end here comma don't worry about it going down to the next line if i were to zoom out just one more you can see that this is still on one line um so going down to the next line here i'm just going to go ahead and copy what we have on that line and paste it in and i'm going to change the second one to user's name so now we need the full name of the user i'm going to go and call this one vacha and set it to 128. you could basically write text or something you wanted that for this as well so if you wanted to have a much longer amount of text inside of it you just write text afterwards we're going to delete primary key because that is only allowed for this column up here we're also going to go and remove the auto increment because we don't need that and that's basically all we want to have here i'm going to copy paste below the next one is going to be the user's email so i'm going to do the exact same thing i'm just gonna change the users uh like the name of the column to user's email and that's pretty much it i'm gonna go down to next line paste it in and then we're gonna change this one to users uid which is the username of this user here then i'm going to go down to next line paste it in again and then we're going to have the password then we're just going to write pwd and we do want to remove the last comma right afterwards here because this is the last entry so we don't want to have a separation comma and once you have this what you want to do is you want to go ahead and click go and once you do that it's going to give you a users table inside your database okay like i have mine already so i don't actually need to submit it again so i'm just going to leave this page and you should go ahead and actually have this useless table here and just to show you with my version of the database here because i do already have some uses inside my database you're not going to have any but i do already have some in there you can actually see the gap that i was talking about inside the user id so you can see that right now it says one three four and some people ask me okay how do we how do we make this person number two instead and then the other one number three and is just really important to point out here that you should not be touching the user id when it comes to this column here just leave it as it is the next thing we're going to do is we're going to go and go inside our signup.inc the php file which right now currently is completely empty because we didn't actually insert any sort of php code in here so what i want to do is i first of all want to start up my php tags because you know we're actually running php code inside this file here i'm going to delete the ending tag because like i mentioned previously with the dbh page we don't actually need to have an ending tag when it comes to just having php code inside this file here now the first thing we're going to do in here is we're going to go ahead and check if the user actually got to this page the proper way which means that if he actually went into our sign up form inside our website and entered data into the form and clicked the submit button did he actually get to the page by clicking that submit button because it is actually possible to go inside our website and just go into the url and say okay i'm just going to go and access signup.inc.php by saying i want to go into the includes folder i want to say forward slash signup dot inc dot php and now i'm actually inside this document here we don't want that to be able to be a thing that the user can do so what i'm going to do in here is i'm just going to go ahead and create an if statement that says if the user actually submitted the form the proper way then we want to run the psp code inside this file here but if they didn't get to this page the proper way then we want to send them back to the sign up page and remember that i mentioned that we passed data from a form using the url what we did here inside our form if we were to go inside our sign up page is i actually went ahead and gave our button a name set equal to submit which means that the data from inside the form here will also include a submit through the button that we put in so what i can do is going back inside our signup.inc.php is i can ask using a php function that is built into php if i have set a particular piece of data inside the url and if it is there then the user accessed this page using the correct method so what i'll do is i'll say okay i'm going to use the function called is set which means that if this is set inside the code then do continue whatever you're doing if this is not set just throw the user back to the signup page or something so i'm going to go ahead and say that we have a global or super globalist called which is a post method that is called submit then the user actually did access this page the proper way so just to show an example of what exactly we did i'm just going to go an echo just echo it works or something and i'm going to go and create an else statement and the else statement is just simply going to send the user back to the sign up page if they did not do this correctly so i'm going to create a header function which is also a function inside php that can you know do something like for example sending the user back to a particular place so i'm going to go and write location call one and then i'm going to go and add the link to the page that i want to send the user to so in this case here we're inside a includes folder at the moment so i want to go back one directory by writing dot dot forward slash and then i want to access sign up dot php so with this if i were to go back inside the website refresh you can see that i didn't actually access this page correctly so it just sent me back to the sign up page but if i were to actually type in some data let's just type something random blah blah blah oh and we do actually get an error message and i do know why we're getting it so if we were to go back inside our document here let's go ahead and go back inside signup.php because inside our action here like i said we're inside an includes folder so we should have written includes forward slash signup.inc the psp so now it should work properly but let's just go ahead and check that we also did the same thing inside our log in we did not so let's just go ahead and say includes forward slash login.inc the php congrats to you if you did actually see this when i made the error and with these changes let's go and go back inside our browser do make sure to refresh the browser otherwise this is not going to work and just go and type everything in one more time let's just go and type the same thing as we did before qwe qwe and as you can see it says it works and we also do get some some stuff here just ignore that thing so now that we know that that works we're going to go and continue actually building the actual script that will do something if the user is trying to sign up inside our website so in between the if statement here what i'll do is i'll go ahead and actually grab the data from inside the url so we have it ready to be used inside our script here and i can do that by creating a couple different variables so i'll write variable name just going to set it equal to and i'm just going to go ahead and copy what we have up here because i'm also going to be grabbing superglobals here in this case i'm going to be grabbing a super global that we labeled as name if i were to go back inside our signup form you can see that the name attribute inside our first input is equal to name which means that in order to grab the data from this input here we need to reference to the super global called name so with that information we can go ahead and just copy paste a couple of times so we're just going to say one two three four times the second one is going to be the email we're just going to write email and the attribute was set to email inside our form as well the third one was going to be the username so i'm just gonna write username and it was set to uid inside the form the fourth one was set to pwd which was the password and then we're also going to do pwd repeat so now we have all the data that we passed in from the form and now we can actually start doing something with the data to for example check if the user signed up correctly the process of trying to figure out if the user made a mistake inside the website is called error handling so we're gonna do a bunch of different error handlers below here to catch any potential mistakes that the user or any sort of mistakes that we might have made inside the website the way we're gonna do this is using a bunch of different functions so what we want to make sure we do is we link to another document inside our website here that has a bunch of php functions in it including the error handles that we want to run so what i'll do here is i'll go ahead and require underscore once first of all i'm going to go ahead and require the dbh file that we created so dbh.inc dot php now do remember we're already inside the includes folder inside this document here so we don't need to say we want to go into the includes folder then i'm just going to go ahead and copy paste this and i'm just going to go and say we also want to connect to a functions.inc the php file now this page we haven't actually created yet so let's just go ahead and do that so i'm going to right click on includes say new file functions dot inc dot php and this document here is going to have a bunch of different functions in it that we can reference to in order to do things inside our website and we're just going to hold on a little bit with making the actual functions because for now i just want to go ahead and use the functions that we haven't created yet in order to just sort of finish up this particular page inside our signup form or inside the signup.inc the php file so going down a couple of lines what i want to do next is i want to go ahead and use the actual functions that we haven't created yet in order to catch any sort of errors that might be happening inside the website the first type of error that i want to see if i can catch is the fact that if the user left any inputs empty which means that he might have forgotten to put anything into the username or the password or the name then i want to tell the user that oh hold on a second there sir you forgot to put something into one of the inputs so what i'll do is i'll create an if statement and inside the condition of this if statement i want to reference to a function like i said that we haven't created yet now all the functions that i'm going to create for these error handlers are going to return true or false meaning that we can just simply say well if this is true then there was an error mistake inside the code if this is false then it means that there's no errors inside the code so i'm going to say that i have a function called empty input sign up parentheses because this is a function and i'm going to set this one not equal to false the reason that we can't just write equal equal equal to true is because if by any sort of chance that this is going to return back as anything besides true or false then it is going to see this as not being an error even though it is technically an error because we want to have false in order for it to continue so what i'm doing here is i'm saying if it's anything besides false then throw an error okay because there's a big difference between is it equal to true or is it not equal to false even though they may seem like the same thing so inside the if statement i just want to say well okay there's clearly a error happening here so i want to send a user back to the sign up page and just sort of start over again so i'm just going to go ahead and copy the header tag that we have down here and paste it in and i also want to include an exit down below here now the exit statement is just basically going to stop this script from running entirely which is why we want to include it in here and i'm also just going to go and include the exit down here below just to sort of have it there to make sure the script stops if anything happens here and then of course we want to go ahead and include an error inside this link here when we send the user back to the sign up page because remember at some point later in this tutorial we will be creating some error messages if they made a mistake you know below the the signup form or something so the user knows what they did wrong so the way we do that is by sending back the user to the sign up page with some information inside the url that we can then use on the page in the same way as we're grabbing data up here in order to get some information about like what is going on exactly at the moment so if i send the user back with this inside the url question mark and then say error is equal to empty input then i can grab this error inside the signup page and say okay well if error is equal to empty input then the user clearly forgot to type something in it's not the form and we need to create an error message that says oh well you forgot to type something into the form the last thing we're going to do here is we're going to go and pass in some variables inside this function here because right now i can't actually see what was submitted by the user to test if they were empty or not so i do need to go inside the parentheses here and pass in these variables so i can use them inside the function to test if they are actually empty so i'm just going to go and copy name paste it in comma email paste it in comma username paste it in comma password paste it in comma and password repeat and there we go so now that we created this one the next thing we can do is we can actually go and check if the username the user typed in is a proper username so what i'm going to do is i'm just going to go and copy exactly what we created here paste it below and i'm just going to go and change the name of the function so it's called invalid uid and remember we haven't created these functions yet these functions is something that we the developer is going to create after we're done with this so just keep in mind that we haven't created these yet so i'm just going to delete all the different inputs that we have here and i'm only going to paste in the username then i also want to check if it is a proper email the user submitted you know in case the user forgot to add an ad symbol or something inside the email then we'll be able to tell if he made a mistake regarding the format of the email so i'll also go and say we want to check for a invalid email and we're going to go and paste in the email down here and now we do also need to remember to change the actual error messages that we send the user back with so it's not going to be empty input for the second one it's going to be invalid uid and then the next one down here is going to be invalid email and then i want to create another one in this case we're going to go and check if the passwords were not the same passwords because remember we wanted the user to include the password two times to make sure that they actually repeated the same password two times in a row just to make sure the user doesn't type anything wrong when it comes to the you know the password they sign themselves up and then suddenly the password doesn't match when they're trying to lock in because they just had to type it once and they might have made a typo the first time so this is a good thing to have the user type the password two times when they try to sign up so to do this i'm gonna call on a function that we create called password match and i'm gonna go ahead and say i want to include the two different passwords inside the password match here so i'm just going to say we have variable password and variable password repeat and then just go ahead and check these two then i'm going to change the error message to say password uh passwords don't match or something this might be too long you can go and include something else if you want to if you think this is this is too much and then i'm going to go and include a final one which is going to be if the username already exists inside the database because if the user is trying to sign himself up as you know username crossing but crossing has already been taken inside the database then we want to tell the user that it's not going to be possible because the username is already taken so what i'm going to do here is i'm going to call in the function called uid exists then i'm just going to go ahead and pass in my connection to the database because we do need to connect to the database to check this error handler here so i want to make sure that i include the connection to the database and i'm also going to include the username because remember we need to actually you know check the username so we need to pass the username into this function to gain access to it and we also want to make sure we change the error message here to username taken so now if we got to this point it means that the user made no mistakes and i just want to point out you yourself can add many more error handlers if you want to like i said in a second we'll actually create these different functions here for now we're just leaving them and then we'll create them soon but you can just go and include more error handlers if there's anything else you want to check if the username has not done one example could be maybe the password should be a little bit longer than like maybe six characters just to make a little bit stronger you can just go ahead and create a function that checks if the password is longer than six characters then everything is okay you know just to give you some examples of what you could do to make this into a more complete login system my purpose with this tutorial is just to kind of show you some of the basic examples here of how we can do error handlers and then you need to think for yourself how to make more of them and then last but not least if we got to this moment the user made no mistakes and there's nothing wrong with whatever they typed in so what we're going to do is we're going to go ahead and sign up the user into our website and again we're going to do that using a function so i'm going to say we have a create user function and inside the parentheses i want to include some parameters because we need to pass in some data into this function for to do something with it i'm going to pass in the connection because we need to connect to the database in order to actually you know sign up a user into the database the next thing we're going to do is we're going to include the the actual data that the user send us so we can actually fill it into the database so we're going to say variable name variable email we're going to say variable username and we're also going to go ahead and say we want to include the password and this is basically everything we need to do inside the signup.inc.php file so now the only thing we need to do to get the signup system working is to just create the functions that we just referenced to inside this page here so now what i'm going to do is i'm just going to go ahead and make things a little bit easier for myself because when we start creating these functions i want to still be able to see the functions inside signup.ink.php but i also want to be able to write inside my functions.ink.php file so i'm just going to go ahead and grab my functions page i'm going to drag it down at the bottom here and just sort of let go so now we can see the functions that we created inside our signup process and we can see the functions page down here that has no functions inside of it so far inside functions.ink the php we're going to go and create the first function after we actually open up the php tags and remember this is going to be a pure php document which means that we're not going to have any sort of closing tag at the end there so in here i want to create this function so i'm just going to go ahead and copy it paste it in and this is going to be the one that checks for empty fields so at the end here we want to make sure we add curly brackets and we also go ahead and state that this is in fact a function that we're creating so creating a function called empty input signup we have all the proper parameters inside the function to make sure they're passed in and then we just want to make sure we write some code in between the curly brackets here what i'm going to do is i'm going to start by creating a variable called results which is going to be what returns the true or false statement once we're done here i'm not going to assign it true or false yet because we haven't actually figured out whether this is true or false before we actually tested the data that was passed in so what i'm going to do below here is i'm going to go ahead and create an if statement and inside the if statement i'm going to use a function called empty which is built into the php language which is going to check whether or not there is data or if there's no data inside whatever i'm pasting inside the function here so what i'll do is i'll go ahead and grab variable name paste it in and what this is going to do is that if there is no variable name inside this variable here like if there's no data inside of it so in this case if the user didn't submit something then it's going to run whatever code is inside the if statement so what i'll do is i'll go ahead and pass in the other different parameters as well so i'm going to include two pipe symbols which means or which is basically okay so if this one is empty or if the next one here is empty so i'm just going to copy paste which is going to be the email then if either one of these two is empty and the user didn't submit anything then it's going to return whatever's inside the if statement you kind of see what we're heading at here so i'm just going to keep copy pasting it in so we have one two three four five so we have one two three four five i'm just going to paste these in one at a time so we have the email username password password repeat and these all need to be not empty in order for this to return as false so if there is any sort of empty inputs then i'm going to say okay variable result is going to be equal to true because there is a mistake here so if there's a mistake we're going to return it as true however if there's no empty fields then i want to make sure the result is equal to false and then at the very bottom here after the else statement i'm simply going to return variable result and the reason that i create a variable result at the top here not inside the actual if statements is because we just have to rewrite the code inside every single if statement and in order to minimize the amount of code we write we just simply state the variable first or declare it as we call it and then return it at the bottom here instead so we don't do everything twice inside each of these statements here so now what we do is we just go ahead and copy paste what we have here paste it below and we're going to go ahead and change the function name to the next one so this one is called invalid uid so we're just going to copy the whole thing with the parameters we're going to paste it in so if the user's username is not a proper username then we want to throw a error message by setting result equal to true so what i want to do here is inside the initial if statement is i don't want to check if there's any empty fields because remember that is what we checked for in the previous function in this one i want to check if there are certain types of characters or if there's not certain types of characters inside the username so i want to run a pregmatch function which is built into the php language and prick match is something that i have done a couple of tutorials on i don't remember if it was javascript or php but this is something where we basically write a search parameter and then if the string that we match up with the search parameter doesn't match up then it's going to throw an error basically so what i want to do here is i want to say okay well i want to add in this pregmatch parameter or the you know the search algorithm that we're using here um so i want to say forward slash i'm not entirely sure that arrow is called in english but a little pointy up arrow and then i want to go ahead and create brackets and inside the brackets we're going to write in the search algorithm that we want to use in order to you know test whether or not the username is properly formatted so i want to make sure that if there is a through set then we want to approve this if there's also a through set as capitalized letters because we should allow capitalized letters inside a username and i also want to check if there is numbers from one two not from one from zero till nine then this is going to get approved then after the brackets i want to make sure we write a multiplication symbol dollar sign and then simply a forward slash and this is going to be the search algorithm that we're going to be matching up with the username that the user typed in the second parameter inside this function here so we're going to say comma space is going to be the actual username that the user submitted so we're going to paste that in now this is going to do kind of the opposite of what we wanted to do because what it's testing here is whether or not this is true or false so what i want to do here is i want to check if this does not return as true so if there is a mistake by writing exclamation mark in front of the function then i want to say okay well there was a mistake so therefore i'm going to set result equal to true which means there's a mistake and then we're going to send the user back to the sign up page then we have the next function so we're just going to copy paste what we have here which is called invalid email so i'm going to paste in the function down here let's just go ahead and move this up so we can actually see what we're doing invalid email so i'm just going to go and copy the name of it paste it in and in this case here we don't want to check for a search algorithm like we did with the to check the username we do actually have a built-in function inside php that can check whether or not an email is correct so what i'm going to do is i'm going to write filter underscore parentheses and inside of here i want to paste in first of all the email that we want to test and i also want to include a statement called filter underscore validate underscore email so this is a built-in function inside php that can simply take a variable and say okay if the first parameter here is a proper email then go ahead and return this as true but because we're checking for errors first that's just a habit you should have when it comes to any sort of programming i want to check if this does not return us true so doing this is just simply all we have to do to check if this is a proper email the next one we want to do here is to check if the passwords are matching so again we're going to copy the function inside our functions document and i want to change the name to pwd match like so and i want to make sure i pass in the password and the password repeat because those are the two things that are matching with each other so what i'm going to do inside this if statement is i want to make sure that variable password is not equal to variable repeat or password repeat because if this one is not equal to the other one then we of course have a error happening we want to make sure that these two are the same thing otherwise the user you know made a mistake when they typed in the password and they have to redo it so if they made a mistake then we send them back with a true statement which means that there was an error and we just basically send them back to the sign up page to redo the thing and then we have the last one this one is the most complicated one of them all and don't worry we're going to get through it it's going to be simple as uh simple as this tutorial here i don't know i couldn't come up with an example so we're gonna go and make this function here so i'm just gonna copy the function paste it below i'm just gonna change the name of it so we have uid exists which is basically checking if the username already exists inside the database and what i'm going to do here is i'm just going to go and delete everything we have inside the function because we don't actually need to have that and the first thing we need to do in order to test if the username exists inside the database is we need to actually connect to the database and see if the username that was submitted is already inside the database table that we just created so what we need to do is we need to create a basic sql statement so i'm going to create a variable called sql i'm going to set it equal to a sql statement so i'm going to say select all from the users table where users uid which is the column that we created inside the users table is equal to question mark now the question mark is a placeholder because we're going to be using prepared statements in order to connect to the database which means that we don't just take the data that the user gave us and just immediately send it to the database because that is that's not too good because it leaves you open to sql injection and other sorts of things so what we want to make sure we do here is that we send in our sql statement to the database first and then we're going to fill in the blanks or fill in the placeholders later on by providing the data which in this case is going to be the variable username now what we can also do just as a bonus is we can go and check if the email has already been taken as well just you know because i get questions about it let's just go ahead and do it so what i'll do is i'll also say or users email which is another column that we have inside the database is equal to question mark then i want to close off with a semicolon and also close off with the semicolon at the end here the first semicolon is to close off the sql statement the second one is to close off the php code okay it's two different things now because we added in the check for the email we of course also need to add in a second parameter so i'm just going to go ahead and copy paste and just change this one to email and we do also need to go back up inside the actual sign up page where we do actually check with these sort of things and add in the email here as well so we're just going to say email you know because we need to pass it into the function to actually test if the email has been taken with this the next thing we're going to do is we're going to go ahead and start with our prepared statement because we need to submit this sql statement to the database in the proper way so on the next line we're going to go ahead and create a prepared statement so we're going to say variable stmt we're going to set equal to and then set it equal to a function called mysqli underscore stmt underscore init which stands for initialization so we're initializing a new prepared statement now in order to actually initialize this prepared statement we do need to tell it what the connection is to the database so i'm going to pass in the connection which is variable con and then what i want to do is after we initialize the new prepared statement is i want to actually use the sql statement up here to prepare this prepared statement with the sql statement does that make sense is that confusing to say okay let me go and explain it in this way instead so you understand the user is actually right now able to go inside our signup form write in some code instead of just writing in you know the name and the email and stuff and by writing code into the inputs they can actually destroy or change our database in any sort of way they want to to prevent this we want to make sure we use prepared statements to make this more secure okay so that's basically what we're doing here we're creating a prepared statement by writing this line of code and then afterwards we're tying this sql statement to the prepared statement to make sure it runs into the database without any input from the user and then later on we add the input from the user to run them separately that will prevent any sort of code to get injected into our database ah so with that explained let's go down to next line let's create an if statement and inside the if statement i want to check if this prepared statement will fail or succeed when i try to run this sql statement in the database because if there is a mistake let's say i wrote users with two ss or something this will actually return as a false preparation or whatever you might call it because there is a mistake inside the sql statement so what i want to do is i want to check for any sort of mistakes that might happen here so i'll say that i have a my sqli underscore stmt underscore prepare parentheses and i want to check if this one fails because we always check if things fails before we check for succeeds that's just a general rule in php or any programming language so i'm going to write an exclamation mark in front of it and i want to go ahead and pass in two different parameters first the statement that we just created and then the sql statement they created up here so now we're saying okay run this sql statement inside the database and see if there's any sort of errors if there is an error it will go ahead and you know send the user back to the signup page with an error message saying something like you know there was a random error or something so what i'll do is i'll just copy the header up here paste it in and it's just going to send the person back to the sign up page and the arrow will be something like stmt failed just like and the statement failed or something so with this we checked for an error message if however this does not fail then we want to start passing in the data from the user so what i'll do is i'll create a built in function called mysqli underscore stmt underscore bind underscore param for parameters parentheses semicolon and what i do here is i first of all say okay where is our prepared statement it is up here called variable stmt the next thing i want to tell it is what kind of data am i submitting to this is it a string is it an integer what exactly am i submitting here in this case here i'm just submitting a couple of strings which means that i am submitting a username and an email it's just basic text so i'm going to write ss inside as our second parameter because we have two strings if i were to have a third string up here i would have to write another s in here just to point it out and the next parameters is going to be the actual data submitted by the user so if the user submitted two pieces of data like in this example here then we just simply pass them in here like so if there's a third one we just add a third one that's just how it functions so we just go ahead and pass in the data from the user and now that we bound the data from the user to the actual statement then we can actually go and execute the statement so i'm just gonna write mysqli underscore stmt underscore execute [Music] if i can write that correctly there we go and i want to make sure i pass in the statement because we need to tell which statement are we actually executing so now what i want to do is i actually want to grab the result from the database because what i'm basically doing is i'm grabbing data if i'm actually grabbing a user from the database by referring to this username and email then it means that the user exists in the database and right now we're checking if the user does not exist in the database because i don't want to sign this person up if the username or the email is already in the database right so that's how that functions so below here i want to grab the data so i'm going to say we have a variable called results data set it equal to mysqli underscore stmt underscore get underscore results and what i want to do here is i want to get the results from this particular prepared statement that we just created up here called stmt remember all the information that we're you know doing here the parameters that we're binding the results that we're getting everything is tied to this particular variable here called statement because that's our prepared statement inside our code and what i want to do now is i want to run an if statement and all i'm doing is i'm checking if there is a result from this particular statement here so what i want to do is i want to say mysqli underscore fetch underscore as suck which means that i'm fetching the data as an associative array which is going to be just an array with you know the columns set to their names inside the array and i want to see if there's anything using result data so basically if i do get some data from the database this is going to return as true if not it is going to return as false so what i'm going to do here is i'm going to go ahead and go down and create an else statement and inside the else statement i just simply want to say variable results is going to be set equal to false and then we just simply want to return this variable here so return variable result now the reason that we haven't written anything inside the if statement yet is going to probably confuse you for now because what i want to do is i want to give this function a second purpose and this is not going to make sense at the moment but it will once again a little bit later on into this tutorial here so what i want to do is if there is data inside the database with this username then i want to grab the data with the username and the reason that is something that we could use this function for to give it an alternate purpose is because once we need to log in the user to the database we're basically going to be checking for the same thing but if this returns as true instead of false then we want to continue doing whatever we're doing inside the login form so if this returns as false inside our signup form we're getting the result that we want if this returns as true then we get what we want inside the log in form if that makes sense it will make sense once we get to log in form so what i'm going to do is i'm going to set a variable row equal to this function here and this is still going to return us true if there's data inside this particular function but it will also assign the data to variable row at the same time so we're just basically creating we're just basically creating a variable while checking for true or false inside this function here then inside the if statement what i want to do is i just simply want to return row which means that i'm returning all the data from the database if this user exists inside the database and then once we get to the login form we get to create the login script we can actually use this data to lock in the user so this function like i said has multiple purposes we can use it for the the signup form and we can also use it for the login form that's kind of nice i think and then the last thing we're going to do inside this function is just simply close down the prepared statement that we created in here so i'm going to say my sqli underscore stmt underscore close parentheses and then we're going to paste in the statement like so so now we create the last error handler for inside our signup script we can actually go ahead and create the function that will actually sign the user up inside our website so what i'm going to do is i'm just simply going to copy paste the function we just created which was called oh let's see if i can get it here uid exists so i'm going to copy it paste it below and i'm just simply going to change the name of it so right now we just pasted uid exists so i'm going to change the name to create user instead so i'm going to copy it and paste it in make sure there's no semicolon behind there and now that we did that we can actually go and move this up again and just see it in full view because we have everything that we need and what i'm going to do in here is i'm going to change the code slightly so instead of checking for a username we're actually going to sign up the person inside the website so instead of saying select all from users which is basically selecting data from the database instead i'm going to insert data into the database so i'm going to delete everything in here except the semicolon at the end there and i'm going to create an insert statement so insert into users parentheses uh values parentheses and then inside the first parentheses here we're just simply going to state the different columns inside the database and they have to be in the proper order so what i'm going to do is i'm going to say well the first one is called user's name and you might ask yourself how do i know what these are called well we did actually create them inside our database so the first one is user's name user's email user's id and user's password now the first column here called user's id remember this one is auto-incremented which means that it automatically creates this by itself we don't have to do anything about it just let it do its own thing so when we do actually insert people into the database just go and start with user's name so i'm going to say user's name users email users id or uid in fact and users password pwd then inside the values we're going to insert the actual values that is going to be inserted by the users so all the stuff that's typed into the signup form so what i'll do here is we're going to be using placeholders because remember we're running prepared statements so i'm going to say question mark question mark and we're going to do this four times because we have one two three four pieces of data and question mark there we go then inside our prepared statement we're going to do a lot of the same stuff here we're going to go ahead and initialize a new prepared statement using the connection to the database then we're going to check if this is going to fail like is this actually possible inside the database given the information with this table here if it does not fail then we continue down to actually bind parameters to it now we do need to change these parameters of course because we don't have two pieces of data we have one two three four pieces of data so one two three four and we're going to go ahead and fill in the proper data here so we have the name the email then we have the username and we have the password but now there's going to be a thing here that we need to talk about which is hashing the password because right now if i were to just insert the password into the database if there was a hacker or if some person were to gain access to the database they would know all the passwords of all the users inside the database so we need to make this a little bit more difficult to understand so we're going to do something called hashing to the password to make it into a bunch of gibberish or you know some random strings and and symbols to make it unreadable so what i'm going to do is before we actually bind the parameters here i'm going to add in a variable called hashed password or hast pwd i'm going to set it equal to a function built into the php language called password underscore hash and i think it's important to point out that hashing methods have changed over time when it comes to the psp language the difference though is that this password underscore hashing method here is automatically being updated to make sure that if there were some kind of hacker or something like if the hashing is no longer a good hash php automatically goes in and updates it to make sure it's secure again so this is the latest form of hashing algorithm from my understanding when it comes to php so we're going to go ahead and say password underscore hash and we're going to go and include the password that was submitted by the user which is variable password then i want to say okay so this is the password and now i want to hash it so we're going to say password underscore default which means that we're using the default password hashing algorithm in order to has this password and with this we're going to go ahead and replace password inside the bound parameters down here with the new password then what we're going to do once we need to lock in the user into the to the website a little bit later is we need to check if this hash password matches up with what the user is typing in when they want to log into the website and don't worry we'll get to that a little bit later so after doing this all we need to do here is we need to execute the statements and then right below here we're going to go ahead and close the statement so we can actually just copy the closing statement from the bottom here and we're just going to go and delete everything leading up to the execute then i'm going to pass in the closing of the statement and all we need to do now is just simply send the user back to i don't know the front page or something you know wherever you want to send the user once they signed up successfully in my case here i'm going to send the user back to the sign up page with a sign up success message so i'm going to say okay eram is equal to none because there was no errors when you tried to sign up inside the website here so with this we have a login system at least we have the signup part of a login system let's go ahead and test it out now do keep in mind that i already have some data inside the database so what i'm going to do is i'm just going to go and delete my data from the database just to make sure we're in the same place so going into our website we're going to go and test this thing out so i'm going to go and fill in some information i'm going to say daniel nelson type in an email of some sort crossing as a username 123 as a password and sign up and we get a unexpected comma on line 16 inside functions.ink the psp so i did make an error so let's just go and see what i did here ah okay so going into line 16 we need to make sure we don't close off the parentheses here because that is not a good idea and we also need to add in a second parentheses at the end here because remember we're closing off this parenthesis at the end and we're also closing off the function parenthesis so make sure there's two parentheses here and not a parenthesis over here okay we get more errors okay so on line 38 there's an extra parenthesis at the end there see people like me make mistakes too okay so it's okay i'm getting suspicious about this now and we're getting more inside our uid exist function inside our functions.inc.php we also need to go down here and make sure we close off with the semicolon if you did that good for you but apparently i forgot to do so so going back into the website trying again let's see if this is working and as you can see we get error is equal to none inside the url up there so if i were to go inside the database and just sort of refresh you can actually see that we have a user inside the database in my case here he's going to be using number five because i did already delete some users this should not bother you leave it alone don't change it to number one by double clicking it and changing it it has to be what it is okay so as you can see we also have the hest password in here which means that we did hash it correctly it is not readable because remember i just typed in one two three it definitely does not say one two three here um so with this we basically have a sign up system but what i want to do is i want to create a couple of different error messages inside the signup form if the user does not sign up correctly or if he does actually sign up correctly let's go ahead and actually tell the user that he's signed up correctly so going into our code we're going to go to signup.php remember i said we're going to return to this file because we're going to include some error messages at the bottom so underneath our form we're going to go ahead and say that we want to include some php code and we could actually technically in this case here we could just you know do it here but let's go ahead and just pretend that you might have some content you want to have afterwards here so just to mess it up for you let's just go and open up a new pair of php tags here inside the php tags what i'm going to do is i'm going to check for a if statements and inside the if statement i want to check if a certain url exists inside the url so what i want to do here is i want to say is set parentheses which we've used before in order to check if the person actually had submitted the form correctly remember on the previous page and in here what i want to do is i want to check for a super global called underscore get now when we check for a underscore post we're checking for data inside the url which we can't see when we check for underscore gets we're checking for data inside the url that we can see and if i were to go inside my website here a very quick way to just sort of tell if this is the thing that you need to write is that we can see that it says question mark error equal to none as soon as there's something equal to something inside the url it is a get method if it said nothing then it would be a post method okay so in this case here we're checking for you know a get method so going inside our code again i want to check for a get method called error just to see if it exists and if it does exist then i want to check what the error messages possibly could be so inside the if statement i want to create another if statement and inside the condition i want to check if this dollar sign underscore get error is equal to empty input so in this case here you know if the user forgot to type something into one of the inputs inside the form it would return empty input after the equal sign so if it does this i want to just sort of return you know some sort of message here i could go ahead and say i want to echo a paragraph that says you forgot to or fill in all fields for example and then what we do here is we just go below and say else if we also want to go ahead and check if it's equal to another error message which in this case here could be invalid uid which is just without capitalized letters and if this is the case we just write some sort of error message here so it could be um you know choose a proper username then we just copy paste the elsif statement until you know we don't have more error messages to write so we just do it a couple of times the next one is going to be equal to invalid email [Music] and we're just going to say choose a proper email then we want to change the next one to passwords don't match like so then we just write passwords doesn't match we also had one called statement failed so stmt failed we're going right here and i'm just going to go ahead and say something went wrong because in this case here we're starting to get into an area where it's a bit too technical for users to to sort of understand what they did wrong so we're just going to go and write something like something went wrong try again um you know because the user shouldn't be expected to know this sort of technical error message so something went wrong and then we need to copy it one more time for a username that might have been taken and we also want to make sure that we get a message if the user typed the right information and everything went smoothly and went the correct way so for next one we want to write username taken [Music] and we just want to say choose another username or something like that username already taken and then down here we want to say error equal to none and just say you have signed up so just to kind of show what we're doing here if i go back inside the web page refresh you can see oh actually let's actually go and move this up because i don't think it's in the right spot so we're going to grab everything sorry about that by the way i know errors like this can be a little bit confusing if you're already struggling so we're going to go and move it up right before the section tag closes at least in my code here and my html markup right before the html tag there so with this going in here because as you can see right now it's down there if i refresh it now says you have signed up and if there would have been an error message you know like uh username taken it would have been username taken instead the error message depends on what is being sent back into the url and that's just simply how that works so with all of this we now need to start on the login script so going inside our login.inc the php file which we also created at some point it is completely empty because of course we didn't create anything in here yet what i'm going to do is i'm going to open up my php tags not going to close them because we talked about that and i'm going to do the same thing i'm going to check if the user accessed this page the proper way by actually submitting the form so again just like before inside the signup.ink.php file we're going to check one is set parentheses i'm going to check for a super global called dollar sign underscore post which is in capitalized and we're going to check for one called submit the next thing we want to do is we want to grab the data from inside the url just like before inside the signup that link the php file so we're just going to say variable username is going to be equal to dollar sign underscore post brackets and say if the user passed in a uid now do remember that if i were to go back inside the login the php file we have two inputs we have one which can be the username or the email i made a typo there as well i don't know what's up with me today i'm making so many typos um username or email and we also have a password now don't worry too much about the fact that it's username or email when it comes to the name here because it might confuse you if you're thinking that okay well how is this going to work out because you know we want to decide what the user is is giving us so if i were to go back inside our login.php we're just going to go ahead and grab it and just name it username even if it's the email they send us it's going to be named username now okay that's how it's going to work so we're going to copy this paste it down and we're also going to grab the password so here we're going to call this one pwd and the same thing in here and just like before again it's a lot of repeat we're doing here we're going to go in reference to the two different documents that we also reference to inside to sign up to link the php which is the database file and the functions file so we're going to say want to require underscore once a dbh.inc dot php close it off i have to stop making errors now so preferably close off each line and we're also going to connect to functions the php now once we've done this we want to start doing error handlers one more time just like inside the previous signup form so what i'm going to do is i'm going to reference to let's actually let's not type everything from now and let's just copy paste what we've already done so i'm going to go inside my sign up page and i'm just going to copy one of these different functions here which is an error handler go back paste it in change the function so now it doesn't say empty input signup instead it says empty input login and we're just going to go and check for username and password and then everything else here doesn't really matter now we do also want to change the link here because we don't want to be sent back to sign up we want to be sent back to log in the php and it's just going to be as an error called empty input if there's something else you want to check for you can just go ahead and type it in here and you know you can come up with as many error handlers as you want to that's just completely up to you after the error handler is here we're going to go ahead and lock in the user so i'm going to call a function called log in user parentheses semicolon and there's going to be three parameters in here first is going to be the connection to the database because in order to lock in a user we need to be able to connect to the database and the second parameter is going to be the username and the third one is going to be the password so with this uh we also want to make sure that if the user access this page incorrectly we also with an else statement send them back to the login form so what i want to do here is i just want to go ahead and again create a header i'm just going to copy from my notes here because we've done it before i'm just going to go ahead and create a header that says i'm going to send them back to the login page and then i'm also going to make sure to exit the script here so this is very simple at least if we compare to the the sign up form so now what we need to do is we just need to create two functions inside the functions document we need to create empty input login and we also need to lock in the user so what i'm going to do is i'm going to take my functions document i'm going to move it down and i'm going to go ahead and just scroll down so we can see the function name at the top here and just make sure we can see the functions document what i'm going to do is i'm just simply going to copy the top one that we created for the sign up which was to check for empty inputs because this is going to be very similar since this is the basically it's basically the same thing we're checking for here so i'm going to go down to the bottom i'm going to paste it in and i'm going to change it to empty input login and i'm just simply going to change the parameters to match the function we wrote up here i'm going to delete all the different empty functions here as well because we don't need them all just need two we're gonna take one empty username and an empty password and that's basically it so we're gonna go ahead and create the next one here which is login user so i'm going to copy the function i'm going to paste it below and i want to make sure it says we're creating a function called login user and then curly brackets afterwards now remember that we already went in and created a function previously where i said that oh it had two purposes well we're going to go and use that function right now so what i'm going to do is i'm going to go ahead and create a variable and i'm going to call this one uid excess which means that we're checking if the user that he typed in the username for or the email already exists inside the database okay and i want to set it equal to the function we created previously so if i were to scroll up here to not create user but uid exists i'm just going to go ahead and copy what we have here and i'm just going to go ahead and paste it in down here so we're going to say paste it in now one thing that is going to confuse you here is the fact that inside our uid exists we have an email submitted that needs to go inside this function here but we don't actually have both a username and an email from the user when he logs in we just have one of them so either the username or the email so how are we going to do this well it's going to be very simple because inside the uid exists function if i were to scroll up to it here you can see that inside the database we're asking for either a username or an email in order for this to be correct right so what i'm going to do is i'm just going to go and pass in variable username into both of these down here so i'm going to copy it paste it inside both parameters and when this returns it will just automatically fit into one of those two we asked about inside the sql statement so doing this means that if the user were to go into the website and try to log in and he were to use his username to do so then it will make this statement here true which means that we're still grabbing the data and this one over here is going to be false which doesn't matter because one of these needs to be true on the other hand if he did decide to use his email address in order to log into the website this statement over here is going to be true and this one over here is going to be false but remember just one of them needs to be true so this is going to be just fine we're just going to go ahead and add in the username for both of these parameters here so the next thing we're going to do here is we're just going to run a quick error handler inside this function we're going to go ahead and check if this function here actually returns as false because if it returns as false it means that the username or the email that he tried to log in with does not exist inside the database so we just want to you know just include that extra error handler there just in case so i'm going to say we have an if statement and i'm just going to go ahead and say if variable uid exists is equal to false then we're just going to go ahead and send him back to the login page with an error message so we're just going to say we're going to create a header and we're just going to send it back to login page with just like the wrong login or something so what we've done so far is we grab the data from the database with this username or email that the user used and with that data the first thing we need to do is we need to go ahead and check the password because remember we hashed it so the password that the user just submitted to us we need to check that version with the hash password inside the database essentially so how are we going to do that well we're going to go and create a variable and we're going to call this one password so pwd hashed and we're going to go and set this one equal to the data from the database you know the the password that is inside the database with that user that the user tried to log in as so we're going to go and say well we have uid exists and because this is a associative array if i were to go back up into uid exist you can actually see that all the data that we're getting from the database gets returned as an associative array means that if i were to reference to a piece of the data i just simply referenced to the column name because an associative array if we remember php is an array where it doesn't use index numbers but instead it's using names for each index inside the array so the the names are just simply the name of the columns inside the database so we're just simply going to write in the name of the database column inside the users table that we want to grab so if we were to say well okay i want password hashed to be equal to the column called users pwd which is the password that we have inside the database then right now we just grab the data from the database and set it equal to this variable here so now we have database data that we can use inside our code so now the next step is just simply checking whether the database password matches with what the user submitted to us so the way we can do this is using a very simple function so i'm going to say we have a variable called check password or pwd is going to be equal to a function called password underscore verify parentheses and inside password underscore verify we're just simply going to pass in the password that the user gave us which is variable pwd and the password from inside the database like so and if these two matches it's going to return us true if it doesn't match it's going to return as false so all we need to do here is go down to next line and say we want to create an if statement where we say okay well does check password equal to false because if it does return us false it means that the two passwords you know the password from the database and the password the user gave us are not the same thing so you know he basically wrote an incorrect password so with this we can actually go ahead and send the user back using a header again just like we did before to the login page with an error message saying wrong login then afterwards we can also say okay but else if this was actually returning as true so we're just going to copy this let's say if it returned as true then what we want to do is we want to lock in the user into the website and this is where we need to start talking about sessions now in order to store data inside a session which is basically informative you can grab onto from anywhere inside the website as long as we have a session running we need to start a session first and that means that we need to go inside here inside the elsif statement and create a function that is built into php called session underscore start if i can spell that correctly there we go and i'm just simply going to start up a new session here so now that we have a new session started i can go ahead and create session variables which is also a super global so if i were to go and say that i want to create a super global called variable underscore session brackets is equal to and then i want to give this session super global some kind of name so in this case here i want to say okay well this super global could for example be the user id which is the id inside the database that one we're not allowed to change and a very simple way to do this is again just like before we go in and reference to the uid access which got returned to us and say that we don't want to grab the user's password but the user's id semicolon then we just go ahead and copy this paste it down because maybe i also want to grab the username just to have it accessible a little bit easier so uid like so and then also grab it from uid inside the database and then last but not least we want to just send the user back to the well let's just go and send it back to the front page because that makes sense so i'm going to send them back to index dot php and just not write anything here i don't think that's necessary so just send them back to the front page and that's pretty much it we have a fully functioning login system right now basically uh we do need to do one more thing which is to change the links inside the navigation in case we are logged in or not logged in we also need to create some error messages in case the user is logging in uh wrong using the login form so there's a couple more things we need to do in order to be like completely done so what i'm going to do is i'm going to go and start by creating those error messages inside the login form so i'll just go back inside our signup.php file let's actually go and move this up here because there's no need to have it down here so by going into signup.php i'm just simply going to copy all this error message you know nonsense that we wrote here and i'm going to go into the login.php file instead and just paste it in in the same place so now all we need to do is we need to match this up to make sure that it matches up with all the error messages we wrote inside our function there so going into our login.ink.php file i want to check for empty input so okay we're just going to go back again to login.php and it does actually have it here so we don't need to change anything there i do also want to go into functions.ink the php and just kind of check the function if we have any error messages we have wrong login we need to make one for that one and that's basically it so for the next one here we're not going to say invalid uid we're going to check for wrong login and just say incorrect login information or something it's something you can write that might make more sense um and then just delete the rest of them because we don't actually need these do be careful you don't delete any accidental curly brackets here that should have been there just pointing that out and now we just need to go in and change the navigation based on if the user is locked in or not so going inside our header file because remember we split up our website into headers and footers and such things so we're going to go into the header file where we have the navigation and right before the sign up and login links i'm going to go ahead and include some php code like so and inside this php code i'm going to create a if statement because first of all i want to check is the user logged in and this by the way is the same way you change content for the user based on if they're logged in or not so what you're learning right now is the same method you use in order to let's say show some other information on the front page or a profile page or something um you know depending on if the user is locked in or not it's the exact same thing you're doing as we're doing right here so with this i'm just going to go ahead and say that we have is set inside this if statement and i'm going to check for a super global called session and check for the session called users uid this is actually incorrect because we called it user uid without any capitalized letters and i'm going to go ahead and check if this just exists inside our website because if this exists it means the user is logged in then all we do in here is we just simply echo out a navigation so if i were to say echo and just simply grab what we have down here and paste it in like so we can actually go ahead and make sure that we are echoing two lines of code instead of one big line like so now right now we're actually checking if the user is logged in so these links are actually not correct so we do need to change them so instead of sign up we're gonna go ahead and say i don't know profile because that makes sense for the next tutorial profile.php and we're just going to call this one profile page i guess then we call the next one log out and then i want to create an else statement so we say else if the user is not logged into our website then we just want to do you know the exact same thing as we had down here originally so we can just actually go ahead and copy all the data here so it matches up with what we have in here like so and like so and then we just delete these so now the only sort of navigation that we show or links inside the menu that we show that is related to logging in or signing up to the website is going to be inside these if else statements here so with this we just have one last thing we need to do because in order to access this session variable remember i said we needed to have a session running inside the website to access these things that means that we have to go to the very top of the website and up here we're going to open up a pair of php tags php not pvp that's something else and in here we're just going to go ahead and say session underscore start which means that on every single page inside the website because we're you know including this header inside every page inside the website we will now have a session started on every single page which means that the user is going to be logged in on every single page inside the website okay so before we actually test this thing i just really quickly want to fix an error that i made inside my html so right now if i were to fill something into the login form inside both inputs it actually tells me that i have empty fields the reason for that is that if i were to go inside my login the php file and go up into the form i right now have my username email placeholder set to name instead of uid so if i were to go back inside my login.ink.php we actually have the proper data send over just to sort of fix that so going back into the website you can now see that it says need to refresh it really quick it now says wrong lock in like it's supposed to um but with this we can actually go ahead and try and lock this person in so if i were to choose crossing one two three you can now see that we're sent back to the front page because we're now logged in it says profile page up here it says log out so the last thing we need to create now is just basically a lockout page where we can lock out the user and that is super quick to do so going inside our website here we're going to go ahead and create a new file inside our project folder here we can actually go ahead and just create it directly inside our includes folder just to skip a step there so inside the includes folder i'm going to create a new file called lockout dot inc dot php and inside this file here we're just going to open up the php tags and what we're going to do in here is we're just going to completely destroy the session variables inside our current session because remember right now the way that the website knows that we're logged into the website is by checking if there is some session variables inside our session so we just completely delete them in order to lock out the user so what we're going to do here is we're going to start a session because without starting a session we can't actually delete the session variables then we're going to go ahead and say we want to say session underscore on set just to kind of unset any sessions we might have and then we're going to say session underscore destroy this is basically going to lock out the user but we also want to make sure we send the user back to the front page after the log out so we're just going to go ahead and include a header function i'm just going to copy it from somewhere else i'm going to send the person back to index dot php like so then if we were to go inside the header we just simply link to this document here so down where we had the logout.php we actually want to link to the includes folder forward slash lockout dot inc the php and i think we're done so let's go and go back inside our website refresh it click log out and as you can see we're now logged out from the website now just as a sort of bonus thing if you want the you know some sort of message to pop up when you log into the website what you can do is you can go ahead and say well hello there mr crossing or something on the front page when you log in so let me just go ahead and copy the php we have inside our header the php file the part that checks if we do have a session variable if so then do something just going to copy that go into my index page and paste it into let's say just a section here make sure we actually also paste in the php opening and closing tags like so [Music] and what i'm just simply going to do here is i'm just going to change whatever it says in here so instead it's just going to echo a paragraph that says let's say paragraph closing paragraph it's just simply going to say hello there space then we want to close off what we have here [Music] and then we just simply include the username which in this case here is just going to be exactly what we have up here as well so we're just going to paste that in and of course we also want to delete whatever is down here so i'm just not going to check for any else statement because if the user is not logged in i don't want to show anything else on the website so with this here what we can do is i can go back to the website and i can go and sign up as another person just to double check ah it does give me the right error messages here so i'll just go ahead and sign up as basic crossing which is the name of my dog sitting over here he's gonna have the same email address just to sort of test it out oh you know we can't have that same username one two three one two three oh username already taken so it does work just to sort of test it out so let's go and give him a new email address and his username is going to be passive123123 sign up you have signed up okay log in username passer123 and it says hello there besser inside my website the last thing i want to show you before we end off the episode is we can also go into log in use our email address 123 and as you can see it says hello there crossing so everything is working like it's intended so this is how we can create a basic basic login system and this is what we're going to be using in future episodes when we're going to start talking about how to create for example a profile page where you can go in and actually click on the profile page and there will actually be a profile page with information about the user so i hope you enjoyed this episode it is very long i'm probably going to include at the beginning of the video that you know just fyi this video is going to be very long so i hope you enjoyed this episode and i'll see you in the next one [Music] [Music] you
Info
Channel: Dani Krossing
Views: 337,320
Rating: 4.9155517 out of 5
Keywords: how to create a complete login system in php, how to create a login system in php, login system in php, login system php, php login system, how to make a login system in php, easy login system, how to make a login system, how to make a php login system, php tutorial, php login, php login tutorial, login tutorial in php, learn php, php for beginners, simple php login tutorial, php beginners, how to make a login form, php, login system security, php login and register tutorial
Id: gCo6JqGMi30
Channel Id: undefined
Length: 117min 38sec (7058 seconds)
Published: Sun Oct 11 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.