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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Username and Password Query:

Status
Not open for further replies.

chromonium

Programmer
Jun 4, 2002
36
FR
Dear Experts,

I have a database in MySQL named main, and a table within that named 'data'. There are two field in this table named "username" and "pass".

How can I cross check to see if the supplied variable correspond with the ones in the database.

Thanks a lot

Many Regards

adam
 
If your passwords are in cleartext (not recommended):

SELECT count(username) from data where username = '<supplied username>' and pass = '<supplied password>'

If the count is greater than 0, the provided credentials match a record in the database.

If the passwords are stored as a hash, it'll be something like:

SELECT count(username) from data where username = '<supplied username>' and pass = [MySQL function used to hash the password in the first place]('<supplied pasword>')

Available MySQL hashing functions are password(), encrypt(), and md5(). And you will have to match the algorithm used to hash the recorded passwords already in the database. See the MySQL online documentation ( for more details. Want the best answers? Ask the best questions: TANSTAAFL!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top