Hi,
I dont know how to check password availabilty from mysql database, Can anyone tell me about with simple and brief explanation in php. if the password is already in db, it should show password is match otherwise password do not match . This should show in the field itself....
Thanks and Regards,

Recommended Answers

All 2 Replies

Passwords shouldn't be stored in the database at all, nor should it be allowed to check if passwords exist.

Usernames are a different story. You could check your db for the entered name (triggered on focus lost or something) and warn the user that the name is taken. The only way of being 100% sure there is only one username is by enforcing a UNIQUE key on the table and catching the exception if the entry is not unique. Otherwise it could still be possible to get a duplicate in, for instance inbetween the check and the actual entry.

Actually, the OP is asking how to validate user password from the database.

However, first, you need to check how you store the password in the database. Practically, you should NEVER store the password in plain text in the database. You need to encrypt it somehow and save in the database. Then when you get user password input, encrypt it the same way you did with the stored data, and then compare the result with whatever in the database. If it doesn't match, then you reject it; otherwise, allow log in.

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.