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

preview_player
Показать описание
In this PHP tutorial you will learn how to create a login system in PHP from, and how to show content after being logged in. You will also learn about error handlers, and MySQL databases, which includes how to make a login form and a signup form. If you get any errors during this tutorial, make sure to check out my solutions at the very bottom of this description! :)

➤ LINKS

User Profile Page video (READ FIRST):

I decided that it would be better to create the Profile Page using Object Oriented PHP (OOP), instead of Procedural PHP. 🙂

OOP is MUCH better for creating BIG systems in PHP, and is more organized and considered the "proper way" of writing PHP.

I have a OOP Login System tutorial that I will link bellow, that I recommend you watch after this one. 🙂 And I will also link my OOP PHP course in case you are completely new to OOP PHP. 😉

Even though you can still follow along on the OOP Profile System video right after THIS Procedural Login System tutorial, I strongly recommend that you watch the OOP Login System first... Since it will be easier to follow along. 🙂

➤ CHAPTERS

00:00:00 - Introduction
00:01:16 - How to get my lesson files
00:02:11 - What will you learn in this video?
00:02:48 - What security will we use?
00:03:41 - It's Procedural PHP, not OOP PHP
00:04:14 - If you get a error along the way...
00:04:48 - A demonstration of what we will make
00:08:20 - What YOU should have ready before we start!
00:12:52 - Creating our Header and Index pages
00:15:57 - Creating our Signup and Login pages
00:26:43 - Creating a connection to our database
00:33:16 - Creating our database
00:42:23 - Creating our Signup script
00:58:23 - Creating our Signup functions
00:58:23 - Testing our Signup system
01:24:46 - Creating Signup page error messages
01:26:47 - Creating our Login script
01:36:35 - Creating our Login functions
01:46:22 - Creating Login page error messages
01:47:47 - Changing our website when user is logged in
01:51:19- Testing our Login system
01:52:20 - Creating our Logout script
01:54:12 - Creating a welcome message when logged in
01:54:44 - Outro

➤ GET ACCESS TO MY LESSON MATERIAL HERE!

First of all, thank you for all the support you have given me!

I am really glad to have such an awesome community on my channel. It motivates me to continue creating and uploading content! So thank you!

I am now using Patreon to share improved and updated lesson material, and for a small fee you can access all the material. I have worked hard, and done my best to help you understand what I teach.

I hope you will find it helpful :)

➤ ERRORS YOU MIGHT RUN INTO!!!

▸"signup=empty"

▸"unexpected }"
If you get this error message:
Parse error: syntax error, unexpected '}'
Then it is because you forgot to close a ) or ; somewhere.

▸"unexpected ;"
If you get this error message:
Parse error: syntax error, unexpected ';'
Then it is because you forgot to close a } or ) somewhere. Probably because you made a mistake with your parenthesis near the "empty()" functions in your signup script.

▸"hashed pwd error"
If you get an error in the script when you hash the password, then it is because you decided not to follow my steps exactly in the video when I created the database table. Make sure you DON'T set the varchar() to a lower value! When you hash the password it will take up a lot of space in this column, and if you set a lower number then it won't fit!

▸"signup=success but database is empty?"
Here there might be a few reasons for your error. 1st is that you made a syntax/spelling mistake in your code. And yes you will claim that your code is identical to mine, but in 90% of the cases people claim this, I still find a syntax error in their code. So check your code for errors!
3nd reason might be because you didn't follow the tutorial 100% when we set up the database at the beginning.

▸"HTTP ERROR 500"
HTTP ERROR 500 is a server error, meaning that you are most likely using an outdated version of apache or mysql. Try updating your servers and make sure that you are using the latest version of PHP.
Рекомендации по теме
Комментарии
Автор

This literally saved my life.
This level of details is what I needed.
Step by step, very clear, nice voice, extremely easy to understand.
So far the best PHP tutorial video I've seen. HUGE THUMBS UP FOR YOU.
Just thank you man!!

ezuolvm
Автор

There are a lot of tutorials on youtube covering php and mysql by non-native speakers of English. Yours are easily the best because even tho English isn't your mother tongue, you speak American English very clearly and well. your content is easy to understand and infinitely practical for developers of every level. I'm an experienced programmer but I'm still learning the intricacies of PHP programming and I love your tutorials the most of all on youtube. I'm a very proud patreon supporter. Tusend Tack!

stormybear
Автор

A couple of years ago I watched your video about login system with php and I made my course project for one of my university classes based around it and last week I even managed to land a job offer with the help of you and that same project. Thanks for your content, keep it up !

DanielK
Автор

Man, this is the best tutorial. Unlike some random guy who just puts the built-in-functions without explaining, this dude explains every single thing. learned a lot of things. Thanks a lot.

navidnawaj
Автор

As a beginner in programming I appreciate you taking the time in explaining what every function is doing. I especially like the side notes 😁

durgasutharsan
Автор

I have never commented in you tube in my lifetime, But I have to appreciate this. Best video in you tube about login system . You're really awesome man! . Thank you so much

yogeshc
Автор

Wow! Less than 15 minutes into the video and I'm already a believer! Your narration and examples are clear and helpful. I'll be signing up for your Patreon! Thanks!

jessigee
Автор

Dude, Thank you so much for this, your content and explantions are a cool mix of professional and relaxed and I really enjoy it. I love the Coder Community thanks to people like you!

nobleinexile
Автор

You are the best development teacher I have ever watched. You explain very well and you make brilliant content. It’s because of people like you that I absolutely enjoy development 😁👌🏽

matthewandersen
Автор

Dani, I used to have the concern about having to pay to get the source code. But after thinking about it, I realize that the value you provide is worth so much more than $5 a month so I am a proud supporter of your work and I hope more people will consider it in that light. Other sites out there charge upwards of $20 a month for material that is not as good as yours.

stormybear
Автор

I could actually cry watching this video! I have been struggling with this for months trying to understand the theory rather than just copying what someone is doing - absolutely amazing video, thank you soooo much!!!

truthteller
Автор

3 days ago I found your video and left a comment, i followed the full tutorial and completed it, this saved me for my assignment next week and I can't thank you enough!

joshl
Автор

Thanks for making such a great tutorial, you literally explained everything the way I expected.
I am just starting in PHP but I think I would be much better if I learn more from you. Really appreciate your effort, keep it up!

sixtusushahemba
Автор

I just want to say Dani, you are awesome.

Finally a programming teacher who is detail oriented. I usually get stuck on the small details that get skipped over by most teachers, like for example that it is MySQLi now instead of MySQL. That or perhaps that detail about not closing the PHP tags on PHP only documents.

I will be pledging to your patreon as soon as I can afford to. I can't begin to tell you how important your content has been.

Oh yeah and I'm 1/4 Danish, it's cool to find a Danish YouTuber.

nomoremrniceguy
Автор

10/10 tutorial if you understand HTML/CSS and can do that on your own, I started with only a tiny amount of the website built and was able to finish the tutorial with my own implementation (that's 80% identical to yours!). Easy to follow along the hours went quick. All of my bugs were fixable and usually some kind of dumb error.

Andrew-pdey
Автор

this tutorial is a banger, I had no idea how to get started on back end, and this gave me all the basics I needed.

lifenote
Автор

I daily receive the same question from different people about having to pay $5 for the CSS file, so before asking here is my answer :)
Yes you do need to be a Patreon supporter to download my lesson files INCLUDING the CSS file, and here are a few reasons why.

1: You should already know CSS at this point, therefore you should not need my CSS file.
2: This is not a CSS tutorial, and my subscribers has previously voted on me not including CSS in my future videos because it took too long.
3: You are not supposed to "just copy" from this video, you are supposed to "learn and apply" to your own website. Which means that ANY of the CSS used in this video is irrelevant to you.
4: People have already supported me on Patreon to get the CSS file, therefore I won't suddenly make it free to download.
5: Majority of my subscribers where the ones who pushed the idea of me using Patreon for my lesson files, and I have their full support in doing so.

I keep getting comments where people want to argue with me on why they should get my lesson material for free. It is how I run my channel so deal with it :)

Dani_Krossing
Автор

Best tutorial ever !! Hope to see how you do your Profile Page very soon.

Madie-sime
Автор

Thank you so much Dani! i tryed to do this login system one month ago when i started coding and i didnt even pass the first part of the tutorial, i've been studying code almost everyday this passed month and today i finally make it to the end, of course i had non working css, errorrs, blank pages and a lot of frustration, but my login system is working fine just as yours now, thank you for the content your videos are the best!

GabrielSilva-yksk
Автор

Great video. It took a couple tries to finish due to some issues on my end, but my log in system is working fine now. Thanks so much Dani. As an absolute beginner, I haven't found another free tutorial as easy to follow as yours. I really got to learn a lot.

core