Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MySQL login for a chat program

Status
Not open for further replies.

Galaxy2003

Programmer
Nov 21, 2003
3
GB
I am trying to make a login for my chat program using mysql but with no luck can anyone help me find abit of code that checks user/password with in a mysql database

so when when people login it will
check sql database then if account is ok it will login or else it will show a error message saying worng pass/name
 
the database(myDB) would have to contain a table(userpass) with 3 fields (one for current number, one with user name and another for the password - stored with mysql password() function). it would look like

table myDB.userpass

no username pass
---- ---------- ------
1 user1 encripted pass1
2 user2 encripted pass2

when a user enters his credentials(username, password) you would use the following query:

'select count(*) as found from userpass where username="' + enteredUsername + '" and pass = password("' + enteredPassword + '");'

if found is not 0 then the credentials are correct and the user can use the program. additionally you can use the 'no' field (which would be defined as unique) to store additional user information in another table of the db.

hope this gives you a hint on how to do this. if you still need more help, post back.
 
I am lost I dont even no how to inport the code lol were do I put it ?? and how do I put it?? I am new to programing with delphi..

can u give me a demo?
 
you would need to create an alias in SQL Explorer or BDE Administrator that would point to mysql (never actually did this so I can't tell you each step of the way but it shouldn't be any different than any other alias creation).

then in your form you would use a database component that points to your newly created alias, and a TQuery component that will pass all query-es to mysql. also include a dataset and you're on your way.

if you've come this far and still need pointers, post back.
 
Ok I am using MySQL.pas for delphi I allready have my database created for members via my website, I just like my chat program to check the database to see if a username or password are within the database if not it will give error but if true it will allow access.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top