WARNING: This version worked correctly to the test server, but unfortunately is not working here. So I'm debugging!
The logon by challenge with AJAX is the solution to log without sending the password, which is very insecure in common connections. In this version, also protects a bit more the database: instead leaving the password for the main database in the PHP code, there is an auxiliary database that has only hashes and encrypted information, including the password for main database, which can only be decrypted with the correct user logon. How it works:
Enter the credentials (e-mail and password) valid or not. They are valid for testing (login OK):
teste1@binho.rb (password: SenhaTeste1)
teste2@binho.rb (password: SenhaTeste2)
teste3@binho.rb (password: SenhaTeste3)
Database fields:
Array ( [0] => Array ( [Apelido] => Teste1 [Email] => teste1@binho.rb [EmailHash] => fab55129f22ede9180129e80074115a3428009a2984f5f49f3dcfab54124a910 [SenhaHash] => 996e09a8e4637dd6f27eeaee43420f95b773e1708d491a48b02363f569c35c74 [AesChaveComSenha2] => iHUJ3EWjq+sGmeEvrzlFrQ3gd/zti0wsT2C5bg45WBnh7KbqyEpKlXzMYpu2iMBeJdZfn+4GG/ADzAZ4+O7bb9/tSnw31chwWQALFM+NQ9c= [AesMestreComChave] => Px/z/aFgcl72OzgGlYL1hg== ) [1] => Array ( [Apelido] => Teste2 [Email] => teste2@binho.rb [EmailHash] => a5ecdcfb2f07b42c4fd6de69441c53ea5b28d0b13c4739a92683063701145a4f [SenhaHash] => 3ead2c60fcd7a33e0a69fae4bd9767fd8bd5e7e8db04b44ea8b67584d1236b13 [AesChaveComSenha2] => AWVs9Wo0Dzeyst2+nH74QLRFIHsx2U3xAy577ktUFs38OMu43xnkllVL9du3HpFb3pynWQp2T4HYtZfzkTs2nfGSq0EMaBUIYmYUlmivJnk= [AesMestreComChave] => B16Z6tQgc1o1qfZAwjWrtg== ) [2] => Array ( [Apelido] => Teste3 [Email] => teste3@binho.rb [EmailHash] => 28248b7310bbc148db3b63fc95065a5e20a7296bea0898df8ca07409f53f1843 [SenhaHash] => a8cbb178d7dae05b7372436f84710a5d8a2fff0f59ef781bb36e624a242a035c [AesChaveComSenha2] => SNX6zsxUllDLfizLd7FxQPdXgKDYFubA+w+oh9OpN6cIpeHEjz9/HuVjiV5DPgGmzGQ2wZvkomWdI4xHl60mf9Ue+qlS7QfWrD5C9t8npQk= [AesMestreComChave] => 5/XF5tid0QvCZKQy+XRY6w== ) )