473,396 Members | 1,789 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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("scott", "tiger", "orcl");
if ( ! $c ) {
echo "Unable to connect: " . var_dump( OCIError() );
die();
}

$s = OCIParse($c, "INSERT INTO personTable
(firstname,lastname,emailaddress) 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.
Dec 21 '07 #1
6 4521

<te****@hotmail.comwrote in message
news:37**********************************@i3g2000h sf.googlegroups.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("scott", "tiger", "orcl");
if ( ! $c ) {
echo "Unable to connect: " . var_dump( OCIError() );
die();
}

$s = OCIParse($c, "INSERT INTO personTable
(firstname,lastname,emailaddress) 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?!!!
Dec 21 '07 #2
<te****@hotmail.comwrote in message
news:37**********************************@i3g2000h sf.googlegroups.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("scott", "tiger", "orcl");
if ( ! $c ) {
echo "Unable to connect: " . var_dump( OCIError() );
die();
}

$s = OCIParse($c, "INSERT INTO personTable
(firstname,lastname,emailaddress) 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.
Dec 21 '07 #3
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("scott", "tiger", "orcl");
* if ( ! $c ) {
* * echo "Unable to connect: " . var_dump( OCIError() );
* * die();
* }

$s = OCIParse($c, "INSERT INTO personTable
(firstname,lastname,emailaddress) 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.. ;)
Dec 21 '07 #4

"Betikci Boris" <pa*****@gmail.comwrote in message
news:c4**********************************@1g2000hs l.googlegroups.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("scott", "tiger", "orcl");
if ( ! $c ) {
echo "Unable to connect: " . var_dump( OCIError() );
die();
}

$s = OCIParse($c, "INSERT INTO personTable
(firstname,lastname,emailaddress) 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!!!
Dec 21 '07 #5
Steve said:
"Betikci Boris" <pa*****@gmail.comwrote in message
news:c4**********************************@1g2000hs l.googlegroups.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("scott", "tiger", "orcl");
if ( ! $c ) {
echo "Unable to connect: " . var_dump( OCIError() );
die();
}

$s = OCIParse($c, "INSERT INTO personTable
(firstname,lastname,emailaddress) 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#1975

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

~A!
Dec 23 '07 #6
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("scott", "tiger", "orcl");
if ( ! $c ) {
echo "Unable to connect: " . var_dump( OCIError() );
die();
}

$s = OCIParse($c, "INSERT INTO personTable
(firstname,lastname,emailaddress) 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.
Dec 23 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Catherine Jo Morgan | last post by:
Can I set it up so that a certain combination of fields can't contain the same entries, on another record? e.g. a combination of FirstName/LastName/address? Or FirstName/LastName/phone? Or...
5
by: Manish | last post by:
The topic is related to MySQL database. Suppose a table "address" contains the following records ------------------------------------------------------- | name | address | phone |...
8
by: Iona | last post by:
Hi Allan, I'm using a nifty piece of code you put on here some time back to do a duplicate entry check as below. I'm using to check for duplicate names. However I am getting an error message on...
0
by: claus | last post by:
Hi, I am not a programmer but tries anyway to program a feature in a form where I am able to copy entries for the form and a subform. I have tried follow the guide here...
5
by: baur79 | last post by:
Hi guys i try to run this code in loop and to pass even the entry is duplicated def email_insert_in_db(email): sql="INSERT INTO emails (email) values ('%s') "%(email)...
2
by: eazyone | last post by:
I can prevent a duplicate ID from being entered, but can't figure out how to go to that specific record. I keep getting an error message on: Me.Bookmark = rsc.Bookmark Its not opening and...
1
by: chicago1985 | last post by:
I have a unique constraint in my Oracle table for 3 fields. If I enter duplicate info on the table using Oracle client I will get an Ora message error ORA-00001 that tells me it is a duplicate entry...
4
by: jbrumbau | last post by:
Hello, I have been successfully using a database I've created for several months to populate an equipment list for a project we've been working on. However, the form has recently stopped working...
4
by: azura | last post by:
how i want to check if there is duplicate entry in my database?? i insert new record which is the same record that i had inserted before,it successfull insert into the database..i don't want that.....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.