sathishauit — 2010-10-19T09:21:48-04:00 — #1
how to avoid duplicate entries in PHP..while i'm typing a new data to input field then posting my data to page that time how to validate the data alerady in database or not..if the data was already there means the form will ask again enter the name like that.... please help to clarify my doubt
rguy84 — 2010-10-19T12:40:02-04:00 — #2
Do you want your form to say "this user name is in use" when you go to create your password field, or when your form is submitted?
cups — 2010-10-19T16:23:43-04:00 — #3
If your question is about trapping duplicate entries as they go into the database and handling that particular error:
Make that field in your table "unique", lets call it username.
If you attempt to input another row with a username which has already been used then mysql throws an error number 1062.
You can test for that error and then tell the user to pick another name because that one is "not acceptable" (avoid saying it is already being used).