B4J Code Snippet Login Example

Hi, thanks for sharing.

I think this is the worst aproach for making a login, because you are requesting the actual password from the database. This is really unsafe, and it can be sniffed ot of the network.

Instead of:
Code:
Dim RS As ResultSet = MySQL.SQLCon.ExecQuery("SELECT * FROM users WHERE T_username = '" & UserNameToCheck & "';")

Its easier and safer something like this:

Code:
Dim RS As ResultSet = MySQL.SQLCon.ExecQuery("SELECT * FROM users WHERE T_username = '" & UserNameToCheck & "' AND T_password = '" & PasswordToCheck & "';")

If you get no records, the password and/or the username are wrong.

Also consider avoiding storing passwords as plain text. you can use a hash function to store them.
 
Back
Top