Log in

View Full Version : How to do management of users account?



toplisek
10-25-2006, 09:14 AM
Hello,
I have many fields like country, phone, street. How to do validation control if e-mail can be just one in database? Example is: User has its account page. He can not change username but he changes his e-mail. Current control will detect in db that there is already used e-mail (he is registered under this e-mail value). So if he would like not to change e-mail, he will have all the time error notification e-mail is already in use.

But this control should be because e-mail should be used only once in db. is this correct?

codeexploiter
10-25-2006, 09:20 AM
Can you rephrase your question in a better manner. At least i am finding it difficult to understand it.

Are you trying to achieve a unique email ID in the user table?

toplisek
10-25-2006, 09:27 AM
User has Account page for changing his account information.
Username and e-mail can be just one in db.

Input box will not be shown for username (can not be changed) but e-mail input box will be possible (user can change his e-mail). So, user decides not to change his e-mail address. Post variable will be the same as in db. Validation report will detect this and report error as following: e-mail address is already in use.
Do you know how to fix this?
If there will not be control of e-mail, other user will put the same e-mail and this should not happen. I hope I was clear as much as possible.

codeexploiter
10-25-2006, 09:53 AM
You need to consider two different situations before implementing this feature.

1. If a genuine user who has entered his/her correct email address at the time of their user registration wants to change some details other than their email address. Now comes the validation part. You can try retrieve a record from the user table based on the email ID entered by the user (In this case user is using the same old email ID), here you have the user name also with you. If the retrieved record's user name is matching with the user name who is trying to change their information, it is clear that this user is genuine. So you can allow him/her to retain their email ID.

The second case

2. A user wants to update their information and changes their email ID. In this case comes the problem you've mentioned in your posting. A user can try to use another user's email address. After the necessary modifications (assume that user has used another user's email address) user presses submit button and the PHP script start processing the data. Like in the first case you are retrieving a user record on the basis of the email ID from the user side. If the email ID is a genuine one then you'll never get a record from your user table so you can proceed and make the updations complete. Now if the email ID is already present there then you'll get a record compare the username of the record and the user name of the user who is trying to update his/her information now, if both are matching then it would be the first case, in all other cases it would a attempt to use an email ID that has already been in the database for another user and you can throw the error messages you want to.

I hope this is clear enough for you to convert this one into PHP Script