You can check http://www.php-login.net/ it has several levels of a login script available. For best practices, check the security guide.
https://www.owasp.org/index.php/Main_Page
Specific security guide for PHP : https://www.owasp.org/index.php/PHP_Security_Cheat_Sheet
And another security guide : http://phpsec.org/projects/guide/
For general best practices for PHP, PHP The Right Way . https://leanpub.com/phptherightway/