login tutorial #1

Build a login system with PHP and MySQL. Set up a users table with ID, username, password, and email fields, then create a Session class in session.php to handle all authentication logic. Upcoming videos cover registration, database inserts, password security, and cookies.
Chapters
Hello and welcome to a new tutorial. In this series, we're going to be learning how to create a login and registering system. Now, it's very simple. All we use is a few classes and it will be perfect. Okay, so we start out with our database. You basically need to have a database. So that you can store everything like your users and their info. I remember that there was this one forum software, but it's called PHP Nuke or something like that. It was some forum software, and it offered a member— some sort of member thing that doesn't need— doesn't rely on MySQL. So if you don't have it, then you should probably— or if you don't have MySQL, you should probably go and check that out. But I really recommend MySQL because it's the best. It's totally easy. It's amazing. So to manage my databases, I'm using phpMyAdmin, and I made a database called _tutorial. You basically, you can make anything that you want, but for this I'm using tutorial. Okay, so now we need to create a table. We'll create one called users, and I don't know how many fields we'll have. One for ID, one for name, one for email, stuff like that. Just do 4. Okay, so we need our ID. This is essential. We'll give it auto-increment. And then we're going to have username, VARCHAR, and we'll just do 255. And then password, which is VARCHAR, and it'll be 32, 32 length, a length of 32. Okay. I'll explain why we choose 32 later. And then email, in case we want to email them anything. And let's save this. Perfect. Okay, so now let's go into our script and we're going to create a file called session.php. This will be like the hub of all of our actions. Our forms will be sent to a file called process.php, which will then process the form and choose an action from session.php. Now I'm not going to create all the classes right— or all the functions and stuff right now, but I'm just going to create The basic template of the class that we're going to use. Okay, so let's make this class, and we're going to start with our tags, and we're just going to say class session, and then under here, session equals new Session. There we go, we have our basic class set up, and now we can access functions really easily outside of this session file. Let's create a little function and I'll explain how you use it. Basically all we need to do is go like session hi. That is all. So if you include session into any of your other files, all you would have to do is say session and then whatever function you need. It makes programming very easy. Let's F5 over here. Oops, screwed up somewhere. You're not supposed to be there. Sorry about that. And there we go, that's pretty much it. So in our next tutorials, in the future ones, we're going to start from First with registering, we're going to insert our stuff into our database, and we're— I'm also going to explain about the password, how the password's going to work. After that, we're going to do logins, then cookies, and so on and so forth. Hope to see you again soon.










