title
PHP Tutorials: Register & Login (Part 5): User Login (Part 1)

description
Want more? Explore the library at https://www.codecourse.com/lessons Official site https://www.codecourse.com Twitter https://twitter.com/teamcodecourse

detail
{'title': 'PHP Tutorials: Register & Login (Part 5): User Login (Part 1)', 'heatmap': [{'end': 577.356, 'start': 547.847, 'weight': 0.74}], 'summary': 'Tutorial series covers the implementation of a user login system, activation process, creating a user authentication form with input fields and handling php errors, providing insights into significant user table fields and the use of global variables.', 'chapters': [{'end': 48.49, 'segs': [{'end': 48.49, 'src': 'embed', 'start': 0.67, 'weight': 0, 'content': [{'end': 4.133, 'text': 'Okay, so this is the part of the tutorial that gets a lot more interesting.', 'start': 0.67, 'duration': 3.463}, {'end': 10.439, 'text': "We're actually going to go ahead and allow our users that have registered to log in.", 'start': 4.293, 'duration': 6.146}, {'end': 13.842, 'text': "Now, obviously we haven't actually registered any users.", 'start': 11.18, 'duration': 2.662}, {'end': 20.969, 'text': 'we just have this users table that we placed this data into, which was the username and the password.', 'start': 13.842, 'duration': 7.127}, {'end': 24.873, 'text': 'These are obviously the two important fields in this case.', 'start': 21.009, 'duration': 3.864}, {'end': 28.315, 'text': "and some other data that we're going to be looking at later.", 'start': 25.633, 'duration': 2.682}, {'end': 39.484, 'text': "This active field also relates to logging in, because if a user has not activated their account, which we'll look at later by email,", 'start': 28.836, 'duration': 10.648}, {'end': 41.085, 'text': "then they won't be allowed to log in.", 'start': 39.484, 'duration': 1.601}, {'end': 48.49, 'text': "So we're going to perform a check, as the user logs in, to see if this value is zero, and if it's zero, we won't let them log in.", 'start': 41.365, 'duration': 7.125}], 'summary': 'Tutorial covers user login process and account activation check.', 'duration': 47.82, 'max_score': 0.67, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/ueruxlD0Smo/pics/ueruxlD0Smo670.jpg'}], 'start': 0.67, 'title': 'User login and activation process', 'summary': 'Covers the implementation of a user login system and the significance of the active field in the users table, determining user access based on its value, with zero indicating a non-activated account.', 'chapters': [{'end': 48.49, 'start': 0.67, 'title': 'User login and activation process', 'summary': 'Discusses implementing a user login system and the importance of the active field in the users table, which determines whether a user can log in based on its value, with zero indicating a non-activated account.', 'duration': 47.82, 'highlights': ['The active field in the users table is crucial for the login process, as a value of zero indicates that the user account has not been activated yet, preventing login.', 'The tutorial focuses on allowing registered users to log in and explains the significance of the username and password fields in the users table.']}], 'duration': 47.82, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/ueruxlD0Smo/pics/ueruxlD0Smo670.jpg', 'highlights': ['The active field in the users table is crucial for the login process, as a value of zero indicates that the user account has not been activated yet, preventing login.', 'The tutorial focuses on allowing registered users to log in and explains the significance of the username and password fields in the users table.']}, {'end': 403.035, 'segs': [{'end': 77.286, 'src': 'embed', 'start': 48.49, 'weight': 2, 'content': [{'end': 50.532, 'text': "if it's one, we'll go ahead and let them log in.", 'start': 48.49, 'duration': 2.042}, {'end': 54.474, 'text': 'So this is extremely simple.', 'start': 51.472, 'duration': 3.002}, {'end': 62.78, 'text': "We're going to be using functions that we're going to place inside of our users.php functions file that we created, which is this one here.", 'start': 54.594, 'duration': 8.186}, {'end': 73.167, 'text': "Remember that's within our functions folder and it's called or included with init.php, which subsequently is included at the top of our pages here.", 'start': 62.84, 'duration': 10.327}, {'end': 77.286, 'text': "So we're obviously dealing with a widget.", 'start': 74.784, 'duration': 2.502}], 'summary': 'Creating a simple login function within users.php for widget interaction.', 'duration': 28.796, 'max_score': 48.49, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/ueruxlD0Smo/pics/ueruxlD0Smo48490.jpg'}, {'end': 175.572, 'src': 'embed', 'start': 125.68, 'weight': 1, 'content': [{'end': 127.041, 'text': 'Now within here, we need a form.', 'start': 125.68, 'duration': 1.361}, {'end': 129.423, 'text': "So let's go ahead and build the basis for our form.", 'start': 127.421, 'duration': 2.002}, {'end': 132.425, 'text': "That's the action and the method.", 'start': 129.643, 'duration': 2.782}, {'end': 134.446, 'text': "And we'll end the form there.", 'start': 133.445, 'duration': 1.001}, {'end': 136.027, 'text': "So we've now got this form.", 'start': 134.966, 'duration': 1.061}, {'end': 140.67, 'text': "The action, we're going to post this data to login.php.", 'start': 136.848, 'duration': 3.822}, {'end': 142.952, 'text': 'And the method is going to be post data.', 'start': 140.75, 'duration': 2.202}, {'end': 146.835, 'text': "So obviously, there's differences between post and get data.", 'start': 143.793, 'duration': 3.042}, {'end': 148.196, 'text': "But I won't go into that just now.", 'start': 146.875, 'duration': 1.321}, {'end': 153.479, 'text': "If you haven't looked up post and get data already, it's a good idea that you do so.", 'start': 149.076, 'duration': 4.403}, {'end': 162.444, 'text': "Okay, so I'm going to create an unordered list to display or structure the form.", 'start': 154.76, 'duration': 7.684}, {'end': 168.348, 'text': "Regardless of whether that's your preferred method, I'm going to be doing so.", 'start': 164.486, 'duration': 3.862}, {'end': 175.572, 'text': "So I've created an unordered list and I'm going to give this an ID of login.", 'start': 168.528, 'duration': 7.044}], 'summary': 'Creating a form with action post to login.php and method post data.', 'duration': 49.892, 'max_score': 125.68, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/ueruxlD0Smo/pics/ueruxlD0Smo125680.jpg'}, {'end': 283.142, 'src': 'embed', 'start': 253.722, 'weight': 0, 'content': [{'end': 258.527, 'text': "Okay, so the first one's going to be for the username field and the label as well,", 'start': 253.722, 'duration': 4.805}, {'end': 260.909, 'text': "although we're just going to write this as text and have a line break.", 'start': 258.527, 'duration': 2.382}, {'end': 268.433, 'text': "the next one is password and then we've got the submit button and then we've got a link to allow the user to click through to register.", 'start': 261.889, 'duration': 6.544}, {'end': 272.155, 'text': "we've already created the registration page, but there's not much on it.", 'start': 268.433, 'duration': 3.722}, {'end': 278.019, 'text': "so username I'm just going to pull this down and indent, so it looks a bit nicer,", 'start': 272.155, 'duration': 5.864}, {'end': 283.142, 'text': "and I'm going to do a line break and I'm going to create an input field.", 'start': 278.019, 'duration': 5.123}], 'summary': 'Creating form fields for username, password, submit button, and registration link.', 'duration': 29.42, 'max_score': 253.722, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/ueruxlD0Smo/pics/ueruxlD0Smo253722.jpg'}, {'end': 416.087, 'src': 'embed', 'start': 380.599, 'weight': 3, 'content': [{'end': 383.441, 'text': 'This is in the root directory along with our normal files.', 'start': 380.599, 'duration': 2.842}, {'end': 398.391, 'text': 'And this is the file that processes the username and the password and goes off and calls different functions and says does this user exist or has this login been successful or is this user active?', 'start': 384.521, 'duration': 13.87}, {'end': 399.772, 'text': 'so is their account active yet?', 'start': 398.391, 'duration': 1.381}, {'end': 403.035, 'text': 'All them kinds of things this file is going to deal with.', 'start': 400.573, 'duration': 2.462}, {'end': 407.138, 'text': 'So the one thing that we need to do is we need to think about error handling as well.', 'start': 403.855, 'duration': 3.283}, {'end': 416.087, 'text': "How are we going to handle the errors that we pass through PHP and you know say I don't enter anything in the form and I just click submit.", 'start': 407.198, 'duration': 8.889}], 'summary': 'File in root directory processes username, password, and handles error handling for php forms.', 'duration': 35.488, 'max_score': 380.599, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/ueruxlD0Smo/pics/ueruxlD0Smo380599.jpg'}], 'start': 48.49, 'title': 'Creating user authentication form', 'summary': 'Covers the creation of a user authentication form with input fields for username and password, a submit button, and a registration link, using functions from users.php, building a form with action and method attributes, and styling with css.', 'chapters': [{'end': 123.847, 'start': 48.49, 'title': 'Creating login widget', 'summary': 'Discusses the creation of a login widget, using functions placed in the users.php functions file and including aesthetics and form building for user interaction.', 'duration': 75.357, 'highlights': ['The chapter discusses the creation of a login widget using functions placed in the users.php functions file.', 'The widget includes aesthetics and form building for user interaction.', 'The login form will be displayed if the user is not logged in, otherwise, it will show a greeting.']}, {'end': 252.401, 'start': 125.68, 'title': 'Building a form and styling with css', 'summary': 'Covers building a form with the action and method attributes, styling the form using an unordered list with an id of login, and applying css to modify the display of the list items.', 'duration': 126.721, 'highlights': ['Building a form with the action and method attributes The form is created with the action attribute set to post data to login.php and the method attribute set to post data.', 'Styling the form using an unordered list with an ID of login An unordered list with an ID of login is used to structure the form, and CSS styles are applied to modify the display of the list items.', 'Applying CSS to modify the display of the list items CSS styles, such as margin top and list style, are applied to the unordered list with the ID of login to modify the display of the list items.']}, {'end': 403.035, 'start': 253.722, 'title': 'Creating user authentication form', 'summary': 'Discusses the creation of a user authentication form with input fields for username and password, a submit button, and a registration link, along with the process of redirecting to login.php and the functionality of the login.php file.', 'duration': 149.313, 'highlights': ['Creation of input fields for username and password, along with a submit button and registration link The chapter covers the creation of input fields for the username and password, a submit button, and a registration link to allow users to register.', 'Functionality of login.php file The login.php file is discussed, which processes the username and password, calls different functions, and checks user account activity and login success.', 'Explanation of file management for the created files The chapter explains the management of files, including leaving init.php open for future work and creating the login.php file in the root directory for processing user authentication.']}], 'duration': 354.545, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/ueruxlD0Smo/pics/ueruxlD0Smo48490.jpg', 'highlights': ['Creation of input fields for username and password, along with a submit button and registration link', 'Building a form with the action and method attributes The form is created with the action attribute set to post data to login.php and the method attribute set to post data', 'The chapter discusses the creation of a login widget using functions placed in the users.php functions file', 'Functionality of login.php file The login.php file is discussed, which processes the username and password, calls different functions, and checks user account activity and login success', 'Styling the form using an unordered list with an ID of login An unordered list with an ID of login is used to structure the form, and CSS styles are applied to modify the display of the list items']}, {'end': 939.078, 'segs': [{'end': 465.722, 'src': 'embed', 'start': 403.855, 'weight': 0, 'content': [{'end': 407.138, 'text': 'So the one thing that we need to do is we need to think about error handling as well.', 'start': 403.855, 'duration': 3.283}, {'end': 416.087, 'text': "How are we going to handle the errors that we pass through PHP and you know say I don't enter anything in the form and I just click submit.", 'start': 407.198, 'duration': 8.889}, {'end': 419.591, 'text': 'I want to be able to say to the user you need to enter a username and password.', 'start': 416.488, 'duration': 3.103}, {'end': 421.072, 'text': 'And we do this.', 'start': 420.491, 'duration': 0.581}, {'end': 426.356, 'text': "I'm going to create a variable at the top of init.php and this is just going to be a sort of global.", 'start': 421.072, 'duration': 5.284}, {'end': 431.199, 'text': "it's not going to be a global variable, but it's going to be a variable that's going to be accessed by every page.", 'start': 426.356, 'duration': 4.843}, {'end': 434.522, 'text': "And it's going to be in an array called errors.", 'start': 431.68, 'duration': 2.842}, {'end': 441.167, 'text': "Now this might seem odd at first but it's just going to be my method of checking through errors and logging any errors we find.", 'start': 435.182, 'duration': 5.985}, {'end': 447.232, 'text': "So you'll know why I've done this in a moment when we get down to the nitty gritty in login.php.", 'start': 441.547, 'duration': 5.685}, {'end': 460.197, 'text': 'Okay so we obviously need to access specific functionality within login.php and we need to access within our core directory our users functions.', 'start': 448.826, 'duration': 11.371}, {'end': 465.722, 'text': "Now we're obviously not going to include our users functions file directly in here,", 'start': 460.758, 'duration': 4.964}], 'summary': 'Implementing error handling and creating a global variable for logging errors in php.', 'duration': 61.867, 'max_score': 403.855, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/ueruxlD0Smo/pics/ueruxlD0Smo403855.jpg'}, {'end': 547.847, 'src': 'embed', 'start': 520.219, 'weight': 6, 'content': [{'end': 526.605, 'text': 'so we say if empty dollar underscore post is equal to false.', 'start': 520.219, 'duration': 6.386}, {'end': 532.211, 'text': "I'm using the triple equals operator which is essentially checking for type as well.", 'start': 527.106, 'duration': 5.105}, {'end': 534.674, 'text': "You don't need to do triple equals but I prefer to.", 'start': 532.251, 'duration': 2.423}, {'end': 543.223, 'text': "we're now going to define two variables, which are username and that's going to equal something here, and password,", 'start': 535.775, 'duration': 7.448}, {'end': 547.847, 'text': 'and this is going to equal something here, and the two things that they equal are the posted values.', 'start': 543.223, 'duration': 4.624}], 'summary': 'Using triple equals operator to check type; defining username and password variables from posted values.', 'duration': 27.628, 'max_score': 520.219, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/ueruxlD0Smo/pics/ueruxlD0Smo520219.jpg'}, {'end': 577.356, 'src': 'heatmap', 'start': 547.847, 'weight': 0.74, 'content': [{'end': 559.843, 'text': 'so dollar underscore post username and here dollar underscore post password.', 'start': 547.847, 'duration': 11.996}, {'end': 561.484, 'text': "so let's just go ahead and test this out.", 'start': 559.843, 'duration': 1.641}, {'end': 567.747, 'text': "I'm going to go and echo username and then I'll just echo, I'll pop a space on there and I'll do password.", 'start': 561.484, 'duration': 6.263}, {'end': 577.356, 'text': "so let's go back to our page and I'm going to type in Alex and password login.", 'start': 567.747, 'duration': 9.609}], 'summary': "Testing username 'alex' and password for login.", 'duration': 29.509, 'max_score': 547.847, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/ueruxlD0Smo/pics/ueruxlD0Smo547847.jpg'}, {'end': 692.026, 'src': 'embed', 'start': 662.405, 'weight': 4, 'content': [{'end': 663.746, 'text': "But we don't want it to just say value.", 'start': 662.405, 'duration': 1.341}, {'end': 665.747, 'text': 'We want it to display the error.', 'start': 663.786, 'duration': 1.961}, {'end': 670.711, 'text': 'So you need to enter a username and password.', 'start': 665.848, 'duration': 4.863}, {'end': 672.832, 'text': "That's relatively straightforward.", 'start': 671.271, 'duration': 1.561}, {'end': 680.217, 'text': "Now, we're not actually going to display any data out here because we need to create some kind of function to output our errors.", 'start': 673.753, 'duration': 6.464}, {'end': 692.026, 'text': "all this is actually doing is it's storing these line after line of errors within this errors array,", 'start': 684.642, 'duration': 7.384}], 'summary': 'Create function to display errors when entering username and password.', 'duration': 29.621, 'max_score': 662.405, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/ueruxlD0Smo/pics/ueruxlD0Smo662405.jpg'}, {'end': 839.464, 'src': 'embed', 'start': 813.52, 'weight': 5, 'content': [{'end': 818.766, 'text': 'Now within this function we need to return true or false based on whether the user does exist or not.', 'start': 813.52, 'duration': 5.246}, {'end': 820.688, 'text': 'So we need to create a query.', 'start': 819.286, 'duration': 1.402}, {'end': 830.556, 'text': "And that's going to be equal to the MySQL query function, which is going to send a query string to our MySQL database and return some data.", 'start': 822.069, 'duration': 8.487}, {'end': 834.039, 'text': "So in this case, I'm going to say select count.", 'start': 831.257, 'duration': 2.782}, {'end': 837.202, 'text': "So I'm counting a specific field.", 'start': 835.4, 'duration': 1.802}, {'end': 839.464, 'text': "Now we're selecting from the users table.", 'start': 837.382, 'duration': 2.082}], 'summary': 'Create a mysql query to check if a user exists in the database by counting a specific field.', 'duration': 25.944, 'max_score': 813.52, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/ueruxlD0Smo/pics/ueruxlD0Smo813520.jpg'}], 'start': 403.855, 'title': 'Php error handling and login process', 'summary': "Discusses implementing error handling in php using a global variable 'errors' and the process of handling a login form, including user input processing, error handling, and sql query security.", 'chapters': [{'end': 441.167, 'start': 403.855, 'title': 'Php error handling', 'summary': "Discusses implementing error handling in php by creating a global variable 'errors' in the init.php file to manage and log errors across all pages.", 'duration': 37.312, 'highlights': ["Creating a global variable 'errors' in the init.php file to manage and log errors across all pages", 'Emphasizing the need to handle errors in PHP for user input validation and feedback', 'Implementing a method of checking through errors and logging any errors found']}, {'end': 939.078, 'start': 441.547, 'title': 'Php login process', 'summary': 'Explains the process of handling a login form in php, including accessing specific functionality, processing user input, error handling, and sql query security.', 'duration': 497.531, 'highlights': ['The chapter explains the process of handling a login form in PHP, including accessing specific functionality within login.php and our core directory, processing user input, and error handling.', 'It mentions the usage of the triple equals operator in PHP for type checking and the preference for using it.', 'The process of handling errors in the login form is detailed, including appending errors to an array and the need to create a function to output the errors.', 'It explains the creation of a userExists function in PHP for checking if the user exists in the database and the use of SQL query to count the user ID from the users table.']}], 'duration': 535.223, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/ueruxlD0Smo/pics/ueruxlD0Smo403855.jpg', 'highlights': ["Creating a global variable 'errors' in the init.php file to manage and log errors across all pages", 'Emphasizing the need to handle errors in PHP for user input validation and feedback', 'Implementing a method of checking through errors and logging any errors found', 'The chapter explains the process of handling a login form in PHP, including accessing specific functionality within login.php and our core directory, processing user input, and error handling', 'The process of handling errors in the login form is detailed, including appending errors to an array and the need to create a function to output the errors', 'It explains the creation of a userExists function in PHP for checking if the user exists in the database and the use of SQL query to count the user ID from the users table', 'Mentions the usage of the triple equals operator in PHP for type checking and the preference for using it']}], 'highlights': ['The tutorial focuses on allowing registered users to log in and explains the significance of the username and password fields in the users table.', 'The active field in the users table is crucial for the login process, as a value of zero indicates that the user account has not been activated yet, preventing login.', 'Functionality of login.php file The login.php file is discussed, which processes the username and password, calls different functions, and checks user account activity and login success', 'The chapter explains the process of handling a login form in PHP, including accessing specific functionality within login.php and our core directory, processing user input, and error handling', "Creating a global variable 'errors' in the init.php file to manage and log errors across all pages", 'Emphasizing the need to handle errors in PHP for user input validation and feedback', 'The process of handling errors in the login form is detailed, including appending errors to an array and the need to create a function to output the errors', 'Mentions the usage of the triple equals operator in PHP for type checking and the preference for using it', 'Creation of input fields for username and password, along with a submit button and registration link', 'Building a form with the action and method attributes The form is created with the action attribute set to post data to login.php and the method attribute set to post data', 'The chapter discusses the creation of a login widget using functions placed in the users.php functions file', 'Styling the form using an unordered list with an ID of login An unordered list with an ID of login is used to structure the form, and CSS styles are applied to modify the display of the list items', 'Implementing a method of checking through errors and logging any errors found', 'It explains the creation of a userExists function in PHP for checking if the user exists in the database and the use of SQL query to count the user ID from the users table']}