Prevent duplicate record entry

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • teser3@hotmail.com

    #1

    Prevent duplicate record entry

    I have my PHP inserting into Oracle 9i.
    But how do I prevent duplicate record entries?

    I only have 3 fields in the insert in the action page:

    CODE
    <?php
    $c=OCILogon("sc ott", "tiger", "orcl");
    if ( ! $c ) {
    echo "Unable to connect: " . var_dump( OCIError() );
    die();
    }

    $s = OCIParse($c, "INSERT INTO personTable
    (firstname,last name,emailaddre ss) VALUES
    ($_POST[firstname],'$_POST[lastname]','$_POST[emailaddress]'");
    OCIExecute($s, OCI_DEFAULT);
    echo "Record successfully entered";
    ?>


    How do I prevent duplicate record info and show the user they entered
    duplicate info.
  • Steve

    #2
    Re: Prevent duplicate record entry


    <teser3@hotmail .comwrote in message
    news:37529850-5b2a-4f25-90e7-8db269679baa@i3 g2000hsf.google groups.com...
    >I have my PHP inserting into Oracle 9i.
    But how do I prevent duplicate record entries?
    >
    I only have 3 fields in the insert in the action page:
    >
    CODE
    <?php
    $c=OCILogon("sc ott", "tiger", "orcl");
    if ( ! $c ) {
    echo "Unable to connect: " . var_dump( OCIError() );
    die();
    }
    >
    $s = OCIParse($c, "INSERT INTO personTable
    (firstname,last name,emailaddre ss) VALUES
    ($_POST[firstname],'$_POST[lastname]','$_POST[emailaddress]'");
    OCIExecute($s, OCI_DEFAULT);
    echo "Record successfully entered";
    ?>
    >
    >
    How do I prevent duplicate record info and show the user they entered
    duplicate info.
    gee, you could just delete any record that may exist for that first/last
    name and email address. or, you could query the table to see if the record
    existed. this is not only such an RTFM question, it's also a brainless one.

    and let me guess, you're the kind who's code is littered with meaningful
    variables like $tmp...right?!! !


    Comment

    • pritaeas

      #3
      Re: Prevent duplicate record entry

      <teser3@hotmail .comwrote in message
      news:37529850-5b2a-4f25-90e7-8db269679baa@i3 g2000hsf.google groups.com...
      >I have my PHP inserting into Oracle 9i.
      But how do I prevent duplicate record entries?
      >
      I only have 3 fields in the insert in the action page:
      >
      CODE
      <?php
      $c=OCILogon("sc ott", "tiger", "orcl");
      if ( ! $c ) {
      echo "Unable to connect: " . var_dump( OCIError() );
      die();
      }
      >
      $s = OCIParse($c, "INSERT INTO personTable
      (firstname,last name,emailaddre ss) VALUES
      ($_POST[firstname],'$_POST[lastname]','$_POST[emailaddress]'");
      OCIExecute($s, OCI_DEFAULT);
      echo "Record successfully entered";
      ?>
      >
      >
      How do I prevent duplicate record info and show the user they entered
      duplicate info.
      In my opinion you should correctly use unique indexes on your table. That
      way the query will return an error which you can then catch and return to
      the user.


      Comment

      • Betikci Boris

        #4
        Re: Prevent duplicate record entry

        On Dec 21, 2:57 am, "tes...@hotmail .com" <tes...@hotmail .comwrote:
        I have my PHP inserting into Oracle 9i.
        But how do I prevent duplicate record entries?
        >
        I only have 3 fields in the insert in the action page:
        >
        CODE
        <?php
        $c=OCILogon("sc ott", "tiger", "orcl");
          if ( ! $c ) {
            echo "Unable to connect: " . var_dump( OCIError() );
            die();
          }
        >
        $s = OCIParse($c, "INSERT INTO personTable
        (firstname,last name,emailaddre ss) VALUES
        ($_POST[firstname],'$_POST[lastname]','$_POST[emailaddress]'");
        OCIExecute($s, OCI_DEFAULT);
        echo "Record successfully entered";
        ?>
        >
        How do I prevent duplicate record info and show the user they entered
        duplicate info.
        You have to compare the entries considering the time, the remote
        address and the values, if all the same (for time consider seconds
        indeed) it will show a possible sql injection first entry must be
        saved the other must be deleted.. Rest is few scripting.. ;)

        Comment

        • Steve

          #5
          Re: Prevent duplicate record entry


          "Betikci Boris" <pardust@gmail. comwrote in message
          news:c4a99ce2-fed1-4c4b-b6c1-b27167e23bd9@1g 2000hsl.googleg roups.com...
          On Dec 21, 2:57 am, "tes...@hotmail .com" <tes...@hotmail .comwrote:
          I have my PHP inserting into Oracle 9i.
          But how do I prevent duplicate record entries?
          >
          I only have 3 fields in the insert in the action page:
          >
          CODE
          <?php
          $c=OCILogon("sc ott", "tiger", "orcl");
          if ( ! $c ) {
          echo "Unable to connect: " . var_dump( OCIError() );
          die();
          }
          >
          $s = OCIParse($c, "INSERT INTO personTable
          (firstname,last name,emailaddre ss) VALUES
          ($_POST[firstname],'$_POST[lastname]','$_POST[emailaddress]'");
          OCIExecute($s, OCI_DEFAULT);
          echo "Record successfully entered";
          ?>
          >
          How do I prevent duplicate record info and show the user they entered
          duplicate info.
          You have to compare the entries considering the time, the remote
          address and the values, if all the same (for time consider seconds
          indeed) it will show a possible sql injection first entry must be
          saved the other must be deleted.. Rest is few scripting.. ;)

          WHAT?!!!

          time and remote address have *nothing* to do with duplicate entries, nor do
          they have ANYTHING to do with sql injections!!!


          Comment

          • My Pet Programmer

            #6
            Re: Prevent duplicate record entry

            Steve said:
            "Betikci Boris" <pardust@gmail. comwrote in message
            news:c4a99ce2-fed1-4c4b-b6c1-b27167e23bd9@1g 2000hsl.googleg roups.com...
            On Dec 21, 2:57 am, "tes...@hotmail .com" <tes...@hotmail .comwrote:
            >I have my PHP inserting into Oracle 9i.
            >But how do I prevent duplicate record entries?
            >>
            >I only have 3 fields in the insert in the action page:
            >>
            >CODE
            ><?php
            >$c=OCILogon("s cott", "tiger", "orcl");
            >if ( ! $c ) {
            >echo "Unable to connect: " . var_dump( OCIError() );
            >die();
            >}
            >>
            >$s = OCIParse($c, "INSERT INTO personTable
            >(firstname,las tname,emailaddr ess) VALUES
            >($_POST[firstname],'$_POST[lastname]','$_POST[emailaddress]'");
            >OCIExecute($ s, OCI_DEFAULT);
            >echo "Record successfully entered";
            >?>
            >>
            >How do I prevent duplicate record info and show the user they entered
            >duplicate info.
            I'm no Oracle guru, but don't they have primary keys? Hell, if all you
            want is to prevent dupes, make all three fields a combined key.

            http://download-uk.oracle.com/docs/cd/B10501_01/server.920/a96524/c22integ.htm#19 75

            Or you could do a select count(*) (However oracle phrases it) where the
            fields match.

            ~A!

            Comment

            • Gordon

              #7
              Re: Prevent duplicate record entry

              On Dec 21, 12:57 am, "tes...@hotmail .com" <tes...@hotmail .comwrote:
              I have my PHP inserting into Oracle 9i.
              But how do I prevent duplicate record entries?
              >
              I only have 3 fields in the insert in the action page:
              >
              CODE
              <?php
              $c=OCILogon("sc ott", "tiger", "orcl");
              if ( ! $c ) {
              echo "Unable to connect: " . var_dump( OCIError() );
              die();
              }
              >
              $s = OCIParse($c, "INSERT INTO personTable
              (firstname,last name,emailaddre ss) VALUES
              ($_POST[firstname],'$_POST[lastname]','$_POST[emailaddress]'");
              OCIExecute($s, OCI_DEFAULT);
              echo "Record successfully entered";
              ?>
              >
              How do I prevent duplicate record info and show the user they entered
              duplicate info.
              Just put a unique first name/last name constraint on your table. Go to
              an SQL related group to find out how, or better yet read the manual.

              Comment

              Working...