Register the user in the database | PHP and MySQL secure login system | Part 1
HTML-код
- Опубликовано: 10 сен 2024
- Hi guys. In this tutorial we are going to create a secure login system with php and mysql.
We are gonna have a register page, a login page, a forgot password page, and an user account page where the user is going to be redirected when he logs in successfully.
Every input field will have a proper and secure validation, so you can easy implement the code in a live website.
This is the first video of a three series and we are going to see how to connect to a database
and register the user.
To learn about prepared statements you can watch the video:
• How to write mysql pre...
or read the article:
digitalfox-tut...
You can buy me a coffee and get the whole source code in a zip file.
The code is updated and uses the PHPMailer library to send emails.
www.patreon.co...
If you don't know how to configure PHPMailer watch this video:
• Send Email from localh...
or
Read the article on my website.
digitalfox-tut...
what a nice tutorial to watch. Thanks for making this!
Thank you! Cheers!
This will help in my Final Year Project !! Thanks ❤
Perfect!
Thank you, this tutorial was very concise and well explained.
You're welcome!
Appreciate your work!
Thank you
This is very valuable content, bro. Thank you.
Thank you
Hi, downloaded src code from ur site, setted up db and everything, registration isn't working. Says An error occurred. Please try again. Other things like resetting password, login for manually added user working correctly. DB Log is empty too
Hey i just downloaded the files, and everything is working, registration to. As for the log file check the files permissions.
If i think of something on what goes wrong on your side, i will get back to you.
It worked for me after writing 'root' in the definition for USERNAME in config.php but I'm a complete beginner so you'll probably know more about this than me :)
@@rosawolke2788 thank you so much!!!
This explained well!
Thank you Haley
"Hello sir, I'm a junior web developer and I'm working on a project that requires a login and registration system. I'm a bit confused about a piece of code I've come across. What would happen if I use the following PHP code for registration?
// Class definition
class Register {
public function register($username) {
// Codes to handle username with session
}
}
// Create object
$register = new Register();
// Method call
echo $register->register($username);
Would this kind of code structure work if it was made good or is it better to use this kind of structure.
Thank you so much .
Yes, you can use OOP to create a registration system. I prefer to create code using objects, it's easier to maintain and it's easier to move your classes from a project to another.
"FILTER_SANITIZE_STRING" seems to be deprecated in PHP 8.1
Yes i know, we have to use htmlspecialchars() instead.
Hey George! I follow along with your tutorial, but I am not able to login even if I input a valid credentials on it.
Hey, in most cases when we typing along we make typos. Did you check for any typing errors in the login function?
Compare your loginUser function with the one on this page digitalfox-tutorials.com/tutorial.php?title=Coding-a-secure-login-system-with-php-and-mysql
Thank you, this was well explained & helpful :)
Thank you too
"if($password != $dbpass) {" you are using loose comparisons which might be still somehow vulnerable
Hey, where did you get this line of code? I use the password_verify function to check the password that is stored in the database.
Why you dont close the php tag?
If you have a php file and you are writing only php, you don't have to.
@@DigitalFox-tutorials and it is more efficient because you are not constantly stopping and starting the interpretor