Preventing Multiple Identical Entries

Discussion in 'PHP' started by Tintumol, Dec 30, 2010.

  1. #1
    i guyz,

    i want to know how i can prevent my program from entering the same entry when i refresh the page?

    Here's my code:

    the form:

    the course_man page:

     
    Tintumol, Dec 30, 2010 IP
  2. dsdf

    dsdf Peon

    Messages:
    35
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Hiya...hard to read :).

    My suggestions:
    1. After submit data, redirect to other page, or
    2. When submit data, check is it some content of the input already inserted or not? SELECT * WHERE content = $_POST['content'] or something like that.
     
    dsdf, Dec 30, 2010 IP
  3. tprinty

    tprinty Peon

    Messages:
    10
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    You could add a primary key on the database table so that only 1 value may be inserted. Any insert with the same value will fail.
     
    tprinty, Jan 2, 2011 IP
  4. EricBruggema

    EricBruggema Well-Known Member

    Messages:
    1,740
    Likes Received:
    28
    Best Answers:
    13
    Trophy Points:
    175
    #4
    Or make unique, but that's not realy handy.

    To prevent do not SELECT * but one field, you just want to check if something exists nothing more!
     
    EricBruggema, Jan 3, 2011 IP