Hello.. I already coded this example: http://www.phpeasystep.com/phptu/6.html I know exactly how can I create a user login from scratch. But that uses deprecated mysql function. Also mysqli is now deprecated. I could use PDO, but I can maybe do something else. Please dont include user codecanyon user login management. What I need to know if this can be done with less lines of code without using Frameworks.
A login-system doesn't really need to take that many lines of code, but usually you want to include error-checking, reporting back to the user, and maybe also a way to get a password-reset if the user forgets the password etc. All this builds up a bit of codelines - but then, lines of code isn't necessary bad, as long as they all serve a function. Besides - mysqli_ is NOT deprecated. Not sure where you got that notion, but it's false. You need a form for login, username/password, and a processing-file (if you don't do that in the same file, which of course is perfectly possible) You also need a db-backend for storing username/password (hashed, salted) and other needed stuff. Then you can add other functionality as you go along. The tutorial you pointed to is garbage, btw. The code is crap. Tables to set up a form? No. Using mysql_? No. Adding ob_start() and ob_flush() for PHP5? Why? Pointing to "encrypting" the password? No. You do NOT encrypt a password. You one-way-hash a password. Encryption can be reversed - hashing "can't" - as long as it's properly done. Besides, there are plenty of better ways to create a hashed password in newer versions of PHP. Forget what you're looking at, find a better tutorial.
I would offload some responsibility and go Oauth or just let folks login with social accounts. will go flesh the relevant code bits in a sec. N.
Thanks for responses! By OAuth you mean the function? http://us2.php.net/oauth I found this Auth: http://hybridauth.sourceforge.net/ I guess that should work on what I want. So its just taking care of sessions and prevent SQLi injection right? Let me know what you think guys.
Yep, you got it. Its hard to avoid a lib entirely but it seems to me you kill a few birds with one stone by letting folks login with facebook, twitter, google, what have you and not even really capture that stuff. Nigel