SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: php

  1. #1
    SitePoint Enthusiast
    Join Date
    Oct 2010
    Posts
    42
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    php

    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

  2. #2
    SitePoint Wizard rguy84's Avatar
    Join Date
    Sep 2005
    Location
    Durham, NC
    Posts
    1,659
    Mentioned
    5 Post(s)
    Tagged
    0 Thread(s)
    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?
    Ryan B | My Blog | Twitter

  3. #3
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    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).

    mysql_errno


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •