Build A Login System in PHP With MVC & PDO | Includes Forgotten Password

preview_player
Показать описание
In this video, you will learn how to create a login system in vanilla PHP using PDO and the MVC pattern. The remarkable thing about this video is that it includes a forgotten password feature, where the user can type in their email to receive a link to a page where they can reset their password.

Another cool thing about this project that separates it out from other projects that focus on the same functionality, is that this project is created using object orientated programming, following the MVC pattern. This means that the created login system is a lot more structured then other peoples, who may have used procedural programming and because of it, ended up writing spaghetti code due its lack of structure.

We will also not be using query parameters on the URL to render out error messages, instead, we will be using flash messages that are generated via a session. This means that these error messages will disappear as soon as the user refreshes the page, regardless of whether they have solved them or not. And this is a huge bonus because it means that users will only be able to see these error messages when they have triggered the associated error, and not through accessing the right URL to display one of these error messages.

📚 Materials/References:

🧠 Concepts Covered:
- Sending an email with PHPMailer.
- Binding data to named parameters in PDO.
- User register, login and logout in PHP.
- MVC pattern in PHP.
- Object orientated basics in PHP.

💻 Technologies used:
- PHP with PDO.
- PHPMailer (email server).
- Apache & MySQL.

If you enjoyed this video then please consider liking 👍 and subscribing. You would be doing me a huge favour if you did this and it would be greatly appreciated ❤️ by me. Likewise, if you have any queries or comments that you want answered. Then please, don’t hesitate post them down into the comments box below. I would love to hear back from you and will answer all of your questions to the best of my ability.

Stay awesome guys. ❤️

#PHP#MySQL#Apache#LoginSystem#WebDev#Authentication#LAMP#Backend#ForgottenPassword#ComputerScience
Рекомендации по теме
Комментарии
Автор

Super dynamic without wasting typing time, as quick as can be without missing one single bit of information. Awesome tutorial and delivers even more than the expected

luisguilherme
Автор

Great tutorial, very detailed and advanced login system, thanks! I will need to go over it a few more times to fully understand it as I am new to php and oop. I Thanks again for a very informative, detailed, practical, and useful tutorial. First class!

photoinshot
Автор

Thank you for the video. It's really the best tutorial I've ever found.

yulib
Автор

You are the best! rly it was very helpful. i bookmarked your lesson

hemxcbl
Автор

Thank you. I learned how to clean the data that is sent from the form to the process that runs with php.

esleiterramirobustamanteat
Автор

thank you, exactly what i was looking for.

siegfriedschmitz
Автор

Thank you for the video. Your tutorial was by far the best I've found. Keep it up dude
Subbed.

elJohnnySilva
Автор

PDO definitely rocks. I have seen the light.

HustleAndStrum
Автор

easy to follow, definitely needed a tutorial like this

oscarl
Автор

Hello. I have customised this to suit my purposes, and it's great. However, I have a question. What is the neatest and best way to connect to the db for a form to search usersName to find users?

CaptainAwesomeVlog
Автор

At 41:25 when you create the if statement for the deleteEmail($usersEmail) condition, I am confused as to how it would not execute the die("There was an error") the first time the user clicks on the send email button.

If the user clicks on the button the first time, since this delete function is called before the insertToken() function - the first time a user enters their email to the input there will not be any row to delete from the table since the insertion occurs after that statement, thus the die("There was an error") should execute the first time around. I am confused as to how it is not happening, any explanation would be appreciated, thank you.

Edit:

My apologies, I just realised PDO::execute() will still return true even if the WHERE condition does not successfully find any corresponding values. I'll leave this comment up if anyone made a similar mistake.

DA-szfr
Автор

Thanks for the instructional video. How can I run it on real server, except localhost.

talhaipek
Автор

have some problem in phpmailer section, I just change the phpmailer setting, but it doesn't work.Is there anything esle that needs to be changed?

pittbrad
Автор

hello dear friend, what about database structure of your project? I've got an error like this " 'my_project.pwdreset' doesn't exist"? what are the fields I need to create to make project working? Thanks in advance! )

alexgora
Автор

I'm following the tutorial this 2023, in 17:12 the FILTER_SANITIZE_STRING is deprecated. Is there any other solution?

alexisaubreybrusola
Автор

Great Tutorial, thx.
Next, how to implement a check is a user is looged in, in all the various page of my website...and redirect to login screen if not authenticated. thx

davidarmand
Автор

Questions.

1) Is there a reason to use varchar(128) rather than tinytext for username, useremail, userpassword? I watched one tutorial in which the guy used tinytext, so I'm uncertain.

2) Is there a reason why everyone is using int(11) for user IDs? Why not 12, for example?

CaptainAwesomeVlog
Автор

Question about "$_POST = filter_input_array(INPUT_POST, FILTER_SANITIZE_STRING);" What do you use now that FILTER_SANITIZE_STRING is deprecated? Thanks.

learntoswim
Автор

it took the d ay to get the it setup and working.... im new to this though.... like the layout. gonna try to use PHP more object orientated

AdamVisitew
Автор

its not a mvc framework. Its a simple oop

joshdevofficial