Set up a login form in php and the first admin login [closed]
I would like to setp up a login form that will included in certain pages.
I found many tutorials that talk about it but, how can I add the "admin" account for the first time ?! In phpmyadmin directly? I can do it but, want it to be encoded with the md5 algorithm. Does anybody know where can I find a ready login system with the session management and all the other stuff?
Thank you very much, regards.
In PHPMyAdmin insert the Admin user's password with md5
INSERT INTO your_user_table (username, password) VALUES ('admin', md5('secret'));
And in your PHP app, use the native md5() function.
Note that md5() is insecure by now and you want to consider sha1 and salting for increased security. See
- https://stackoverflow.com/search?q=salt+security+php
you could make some kind of install script for your software which shows a form where the user enters the admin login data. This install script would add this admin and should be deleted afterwards or at least should it have minimal access rights.
But you also can add admins via phpmyadmin or other MySQL admin tools.
If you are looking for complete login solution you should take a look at some of the major PHP frameworks out there.
For example:
Zend Framework or Symfony
There are many more and most of them offer session management and login solutions. But these frameworks might be a bit of a overkill if you are only looking for a simple login script.
Have a look at ZendFramework and read some tutorials, like
- http://robertbasic.com/blog/login-example-with-zend_auth/
ZendFramework has excellent authentication and session management.
精彩评论