Link to home
Start Free TrialLog in
Avatar of wellso
wellsoFlag for United Kingdom of Great Britain and Northern Ireland

asked on

PHP and Internet Explorer - foreach loop making duplicate entrys

Hi there,

Having problems with IE inserting duplicate entrys into a database from an array of checkboxes in the $_POST header. It only happens on IE and not Firefox and I am completely stumped as to why? Can any shed any light on this?
if($_POST['query']=="add" && count($_POST['rep']) >= 1){
 
  foreach($_POST['rep'] as $value){
 
    $insert = "INSERT INTO DOCSLINKS (LINK_ID, DOC_ID, ORDER_ID) VALUES (LINK_ID_SEQ.nextval, '$value' ,'$am')";
    $statement = oci_parse($connect,$insert);
    oci_execute($statement);
    }
}

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Michael701
Michael701
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of wellso

ASKER

i have print_r the array, each check box holds a primary key value (doc_id) that I am adding to the database. print_r shows only 1 entry per ticked checkbox but the loop inserts 2 records in IE but works fine in Firefox,
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of wellso

ASKER

INSERT INTO DOCSLINKS (LINK_ID, DOC_ID, ORDER_ID) VALUES (LINK_ID_SEQ.nextval, '1091' ,'AM12345')

It only seems to go round the loop once but inserts two records, it puzzles me how it only happens in IE
Avatar of wellso

ASKER

https://www.experts-exchange.com/questions/23791556/IE-cannot-send-post-to-PHP-form-where-Firefox-works-fine.html

Found out the problem, turns out Javascript was submitting the form twice. I have various buttons on the form to perform different functions which trigger onclick events in JavaScript, one of which is submit(); the input type was still set to submit on the offending button leading to dual submissions of the form, I presume Firefox must have catched this and only submitted once, good job I am not designing an eccommerce credit card submission system hehe. Thanks for the help all the same.
Avatar of wellso

ASKER

Thanks for the help, got it sorted in the end : pesky JavaScript handling in IE :)