473,788 Members | 2,759 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

stop duplicat entry in db

3 New Member
Hello

I have a page on which i m placing order. After submitting the form, data is inserted to db successfully but when i refresh the page the duplicate data is inserted to db.

How can i stop this.

Can anybody help me?

Thanx in advance
Dec 13 '07 #1
5 1644
MarkoKlacar
296 Recognized Expert Contributor
Hi,

could you post your SQL query?
Dec 13 '07 #2
Markus
6,050 Recognized Expert Expert
Hello

I have a page on which i m placing order. After submitting the form, data is inserted to db successfully but when i refresh the page the duplicate data is inserted to db.

How can i stop this.

Can anybody help me?

Thanx in advance
[php]
//mysql_num_rows sounds like your savior!

//your mysql result
$query = "some_query ";
$query = mysql_query($qu ery);
$result = mysql_num_rows( $query);
if($result > 1){
# data has already been inserted or page has been refreshed
# don't run any queries to insert data!
} else {
# data is unique
# run mysql queries to insert data
}
[/php]
Dec 13 '07 #3
sejal17
56 New Member
Hello
JUST TRY IT...

After inserting data execute the query and then write:

echo '<script language="javas cript">document .location="'.ba sename($_SERVER['PHP_SELF']).'";</script>'."\n";
try this.
then reply me.
Dec 13 '07 #4
Markus
6,050 Recognized Expert Expert
Hello
JUST TRY IT...

After inserting data execute the query and then write:

echo '<script language="javas cript">document .location="'.ba sename($_SERVER['PHP_SELF']).'";</script>'."\n";
try this.
then reply me.
not what he's looking for; the user could just press the back button and refresh the page from there.

And don't be so pushy.
Dec 13 '07 #5
nitinpatel1117
111 New Member
The way that i stop this happening is by using the php redirect function.

create a flag, i.e. a variable that is picked up using $_get or $post. if this flag is set then insert the sqll query into the database.
after you have done the insert query succesfully, you can redirect to the same page again.

when this page is reloaded it will lose the $_REQUEST variables, that were sent in the initial page request first time.

therefore, the flag will not be set, and the insert query will not get executed


Even if the person presses the back button on their browser. they will not be able to reinsert the data into the database as the brower thinks it is at the same url becuase of the php redirect.

depening on whether you are using session variables, (I can't remember which way around it is)
you may have to redirect to another page and then from this page redirect back to the original page.
Dec 14 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

2
5294
by: 0to60 | last post by:
I have a windows service that when started creates two threads: one thread that runs a TcpListener waiting for TcpClients to connect, and another thread that reads from the resulting sockets. My stop code .Abort()s the threads and .Stop()s the listener. One one of my computers, the service runs like, well...a service. It starts and stops nicely. On a different computer (eventually this service will be running on 50+ machines) the...
45
2769
by: StopThisAdvertising | last post by:
Hi there, We all know Steve Santos. He *really* is an advertising and job-hunting machine. A lot of us have asked him *many* times and in different ways to stop his blatant advertising. This has been repeated for years and years now. Result: Unfortunately nada. He just doesn't give a shit. He is only very offensive in his answers to these requests. Also he has been 'kill-filed' by many of us. Result: Nada. He did not get enough answers...
1
2337
by: Chua Wen Ching | last post by:
Hi there. I am displaying a string which will appear 1 char at a time. The problem is after it display the 1st string, it will keep on continue. When i uncomment the myTimer.stop(), it does not even run at all.. cannot see anything on the command prompt. Any help?
14
7479
by: electrician | last post by:
While running a program that exceeds the array limits it issues an alert. I want to then stop the program after filling in the output boxes with blanks. How do you stop the program? I have worked on this for days and tried searching the net, but have found nothing.
3
11855
by: Goran Djuranovic | last post by:
Hi all, I have a web app running on a local PC that can start and stop windows service on a remote machine, but only when I browse to it locally. If I browse to it from my other PC and try to start/stop the service, it gives me "Cannot open Service Control Manager on computer 'xxx.xxx.xxx.xxx'. This operation might require other privileges." error. Helpfull info: - I am an admin on all 3 PCs - web app is using "Windows" authentication...
8
2051
by: Richard Maher | last post by:
Hi, I am in a mouseup event for button A and I'd like to disable=false button B before starting some work. Is there anyway that an event for button B can then fire before my event processing for button A's mouseup has completed? I beleive event processing to be single-threaded for good reason but I need a "stop" button and it's no good if it doesn't do anything until the other processing has finished :-)
12
3507
by: Birky | last post by:
How can I stop a form from updating the database when a user closes the form? I have a form which is used for referencing, additions, and modifications but every time the form is closed with no modifications the entry which is being displayed is then stored in the database causing duplicates. My hope is to only allow additions and or modifications if they select the proper command button. If they just close the form I would like nothing stored...
1
1515
by: jeganrd | last post by:
i have problem using distinct query. I have table it has 22 fields. call_id is repeted because of maintain the history. when i insert the same record as another record some filelds should change the datas like closed_date, engineer_name, solution_description. the another contacts details never changed. i am select the distinct call_id and i want to retive the all fields. but it throughs duplicat values so give me solution it is...
4
3690
by: =?Utf-8?B?YzY3NjIyOA==?= | last post by:
Hi all, We have many forms on our site that users can fill out and ask questions, request information etc. but somehow, we receive a lot of junk mails (more than two hundreds) within two weeks through these forms. I don't know hot to stop these junk emails. Can you provide some ideas and ways to implement? thank you so much. -- Betty
0
9656
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9498
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10373
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10118
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8995
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6750
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5538
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4074
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3677
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.