Helpful Information
 
 
Category: ASP Programming
Double postings

Hello Board,

I am using an HTML form to post data to my database, but when a users enter contact info into my database I am getting the same info twice, although the user only submits once. Here is my code:


sSQL = "INSERT INTO Lead_Data (username)" & _
"VALUES ('" & User_Name & "')"

Set objConn = Server.CreateObject("ADODB.Connection")
objConn.Open "DSN=", "", ""
objConn.Execute(sSql)
objConn.Close
Set objConn = Nothing
Response.Redirect("addpass.htm")

Can someone help?

Thanks!

You might want to try disabling the submit button with a little bit of client side javascript once the form is submitted in the onsubmit event handler for the form.
This means there is no way the person can submit the form twice if the network is slow. Well not unless they copy the source and take your javascript out at least.

We have run into this problem before also and it is usually related to your IIS set up.

The way to fix this is:

1. Goto IIS Administrative Console
2. Right click on the website where you are having these problems.
3. Go to the Home Directory tab in the properties window.
4. Click on the Configuration button on the Home Directory tab. (It's located toward the bottom right side of the Application Settings area of the Home Directory tab.)
5. Find the .asp extension in the list of extensions and assigned plug-ins.
6. Click on the Edit button.
7. Toward the bottom of that configuration window you should see a "Check File Exists" checkbox. If it is checked, uncheck it.
8. Save your changes.
9. Restart IIS.

Now you should have corrected the double entry to the database.

Why was this happening?

The ISAPI.DLL when "Check File Exists" actually posts twice when it is called from script. Therefore, it is going to insert twice whenever you call the page.

Hope that helps.

Ben Cramer
iPath Solutions
Houston, TX

I am having this same problem.

I checked my IIS settings and "Check File Exists" is not checked, so this is not my problem.

Do you know of anything else that can cause this? It doesn't happen to everyone. I can use our Web site/application just fine, but I have complaints from a few that this double posting is occuring. I also have an employee that is recreating the problem with her computer. This leads me to believe it might be some bug in a certain version of IE. Have you heard anything about this?

Any information you can give will be greatly appreciated.

Thanks,
Marlo

One ineffecient way around it is to do a search first and only to do the insert if the record does not exist. This will stop the double entry problem if the user is clicking submit twice.


I've taught ASP and have seen several beginners inadvertently have 2 objConn.execute instructions by mistake.

Ray

The problem we are having is not that the submit button is being clicked twice. The button is clicked once, but somehow the information is posted twice.

This is happening more and more with all areas of our Web site. The contact form, registering, etc. One in particular that is a big problem is a feature that sends an email message to a list of contacts. The user hits submit only once, and the message is sent twice to each contact. I've gone through the code, it is not a problem there. Also, this is something that has just started recently over the past few weeks. We had no problems before that.

I have started to notice this happening more and more. I am thinking this is some sort of bug in a certain version of IE that has just started to occur. Developers are thinking it is happening because the user is clicking the submit button twice, that that is not what is happening. May be some combination of IE and IIS. It is not happening for all users, but enough to cause real problems.

I am extremely frustrated because I can not find a solution. I've been searching the developer forums and have found nothing about this. Everyone is assuming the user is clicking the button twice.

What type of encoding is the form

IE is surposedly makes a mistake when submitting a form with
ENCTYPE="MULTIPART/FORM-DATA"
and sends the headers twice or something.

This is usually when you are doing some sort of uploading to your site.

What has changed recently that could help point to the cause?

It is not a multipart form...just the default encoding.

I've been trying to think of any changes to the server or site. I can't really think of any other than adding new pages to the site, but that shouldn't affect other existing pages/functions.

Not everyone is having this problem. I can not recreate it with any of my computers, but I have 2 associates that are having the problem on their computers. I can't find anything specific in common with their 2 computers that is different from mine. One is running Win98 with IE6, the other is running WinXP with IE6. I am running WinXP with IE6

We've seen this in a number of areas on our application. Believe it or not we narrowed it down to 1D10T users double-clicking the mouse button instead of single-clicking the mouse button :D

dot

I'd also suggest:

Make a simpler set of files into a simple table and test it. The goal is to determine if it's your coding or the server. A simple app with nothing other than one field into a new table reduces possibilities.

Also,
I forgot which DB you are using, but if it's a client-server Db, check for any triggers that might be doing this.

Ray

I think RayHogan is on to something with his posts. I just wanted to amplify it a bit.

You could create a stored proc that accepts the value you are inserting into the table and checks to see if it is there before running the insert.

If it is there, it returns a parameter that forces the page on to the redirect as if it were entered.

That might prevent the double postings.

We have had the experience that not all user were having this problem. And I can say that it seems that there was an issue with the version of IE that you were using. Users with IE 6 and beyond had experienced the problem and 5.5 and prior versions weren't having this problem.

Have you checked http://msdn.microsoft.com for possible solutions?

They can be fairly helpful with matters of IIS and IE.

Ben Cramer

What version of browser are you running?

I am currently developing an app and am experiencing the same problem!

I have narrowed it down to IE 6. IE 6 will "sometimes" post to a web form twice! I have run sniffer traces and that is exactly what happens. IE 6 posts, then immediately does a reset on the connection. The server replies to the original post but it has been reset. Then, IE 6 opens a second connection using the same session ID and form data. The server then replies and IE displays what the server sent.

The problem is, if you are setting application variables on the form post, those variables will be set twice.

I downgraded to IE 5.00 and everything works fine!

I am using EI 6.0.2800.1106...... and I don't have the problem. I have a co-worker that has IE 6 but a little earlier version than mind and she has the problem. She has been having problems updating it, so we haven't tested if that will fix the problem yet.

Unfortunately it is not a real possibility to tell the public they need to downgrade to IE 5 to use our application. If we could narrow it down to a specific version that would help.

It doesn't sound like there is a solution until the problem becomes more widely known and then may be Microsoft will acknowlege the problem.

If you have access to the logs of your server .. check if the post happens twice or once.

Check on what you are doing after the query.

I had a problem before. A call to send mail --"not exactly a databse thing but hay" was executed twice becuase after it a script didn't run proparly. and caused the page to re-execute.
try to cut off the script right after you update the database by response.redirect("http://somewhereStable")


and is this a constant thing or does it happen once in a while?

Are you using Javascript to post your form submission? Perhaps with an image that when clicked does some form validation and then submits the form?

If you have something like this:

<input type="image" src="whatever.gif" onClick="document.form.submit()">

That will submit your form twice with IE6. IE5 is fine. If you are using an image as a submit button you don't need the javascript. You may already know but I am just trying to narrow down the possibilities!

I've experienced the same thing and solved it with the following

Some basics to check, does this happen on all machines that submit, or only one.

If it is only one, then chances are it has to do with mouse settings on that machine (i.e. double click speed type of thing)

Try checking and submitting on another machine.
If it only happens on one machine, try changing the mouse settings on the original machine. Try submitting on the original machine.

If this doesn't work, then worry about programming around the event.

;)

You have used two different case for SSQL once as ssql and once as sSQL.. shouldn't make a difference but worth trying to change.


another thing you could try after you have closed your connection reopen it and insert another dummy record into the same table.

when the double post happens, open the table and check the order of the records .. if "main, duplicate, dummy" then it is some thing in the ODBC connection. if "main, dummy, duplicate, dummy" then it is something with browser/mouse/user/IIS handling

here is what it might be

<input class="input" type="submit " name="Submit" value="Submit" onClick="javascript:submitit();">

if you use javascript to submit the form

do not use a button type of submit.........it will submit twice

correct code

<input class="input" type="button " name="Submit" value="Submit" onClick="javascript:submitit();">

:o

At least in my implementation.

The only reason to use both a type="submit" and an "onclick=" seems to be to allow the user to hit the enter button to submit the form. (which it won't do if the button type is not submit).

I've run recently into the same problem and had a very hard time determinig why is it so interminnent. mohecan's post gave me a clue:


chances are it has to do with mouse settings on that machine (i.e. double click speed type of thing)

As it turns out, chosing "one click" (i can't tell how exactely it's written in english systems as i use polish one, but i think you know what i mean) setting in mouse settings causes random double posts.

Hope this helps someone :D










privacy (GDPR)