a void inserting duplicted data

Discussion in 'PHP' started by omarali, Nov 12, 2008.

  1. #1
    Hi everyone
    can anyone please tell me how to aviod entering duplicated data into database using 'insert into'. Thanks a lot
     
    omarali, Nov 12, 2008 IP
  2. cornetofreak

    cornetofreak Peon

    Messages:
    170
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #2
    id set a session for that username and make use of the time funcction lil example below

    if($submit){
    if($_SESSION['last_submit'] < time()-100){
    return 'Error';
    }else{
    do some stuff here.........
    }
    }
    summat like that....
     
    cornetofreak, Nov 12, 2008 IP
  3. xenous

    xenous Peon

    Messages:
    102
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    have your table a unique field named id and set it as auto increment then you will never have the duplicate rows. and if is to prevent users to insert duplicate then just add user id in table and set as unique. your question is so general it would be better to see your table structure.
     
    xenous, Nov 12, 2008 IP
  4. joebert

    joebert Well-Known Member

    Messages:
    2,150
    Likes Received:
    88
    Best Answers:
    0
    Trophy Points:
    145
  5. EricBruggema

    EricBruggema Well-Known Member

    Messages:
    1,740
    Likes Received:
    28
    Best Answers:
    13
    Trophy Points:
    175
    #5
    The best way to avoid duplicate data in a database can be done this way.

    1. Setting up unique fields (combining)
    2. Checking if exists in database before inserting (for example with a delay)
    3. INSERT INTO .... ON DUPLICATE KEY.....
     
    EricBruggema, Nov 13, 2008 IP
  6. omarali

    omarali Peon

    Messages:
    9
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Hi, thanks I have don what you said, still if insert for example 'omar','ali' as a data and will stored again despite of the data been their.
     
    omarali, Nov 13, 2008 IP