I have a small desktop application created, i wan to create a login function for this. i have a database using MySQL which stores user name and password. i wan to know how to compare the user name and password entered in the text field with the data in the database.

I have a small desktop application created, i wan to create a login function for this. i have a database using MySQL which stores user name and password. i wan to know how to compare the user name and password entered in the text field with the data in the database.

There are a few steps you need to do in order to complete this.

1) Make a connection to the database
2) Create a query trying to find the required information from the required table (possibly login?) based off of the supplied username/password
a) if a record is returned then the user exists
3) display a message.

Building your query as a hard coded string could pose some problems with SQL injection techniques, however once you have information you want from the database you can address that hole.

If you run into problems post your code and we can help out.

Cheers

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.