i need help with login mechanism, i have this application that i am trying to add a login form but i dont know how to authenticate the username and password..
i need to learn how to send the username and password to the database and when the user logs in it should retrieve the password from the database and authenticate if the username and password is correct.

and a code snipet that can help a new member create a new account in the app. ie for non members to create a new username and password, just like openin a new yahomail account.

i need a code snippet that can help me achieve both problems
help from anyone would be appreciated. jwenting,isreal and others pls.

In a separate class write a method that takes two arguments (username, password). That method should query the database using these two arguments, in order to check if there is such record. If the above combination (username, password) exists then the method should return true, otherwise false.
Then create a gui where the user inputs username, password. Take these values, call the above method and if it returns true, then the user should login.

As for creating a new member, in the above class create a method that takes two arguments (username, password) and performs an INSERT in the database.
Then create a gui where the user inputs username, password. Take these values and call the above method.

And you don't specify what will you use for the login form. (.jsp or swing)

In a separate class write a method that takes two arguments (username, password). That method should query the database using these two arguments, in order to check if there is such record. If the above combination (username, password) exists then the method should return true, otherwise false.
Then create a gui where the user inputs username, password. Take these values, call the above method and if it returns true, then the user should login.

As for creating a new member, in the above class create a method that takes two arguments (username, password) and performs an INSERT in the database.
Then create a gui where the user inputs username, password. Take these values and call the above method.

And you don't specify what will you use for the login form. (.jsp or swing)

thanks JavaAddict could you help me with a code snippet to achieve that for jsp and swing?.

This article has been dead for over six months. Start a new discussion instead.