PHP Insert Statement runs twice in Firefox, once in I.E

advertisements

I'm truly stuck here. I have an insert statement that runs twice on Firefox, but (correctly) only once in I.E.

What could be causing Firefox to run the insert statement twice? It only runs this query twice, not the others on the page. I went as far as to comment out ALL other code except for what I'm posting below and it still inserts twice in Firefox.

if((isset($_GET['stepNum']))&&(isset($_GET['idNum']))){
    $stepNum = $_GET['stepNum'];
    $idNum = $_GET['idNum'];

    $startCycleNum = 1;
    $startCycleStatus = 1;
    $cycleGo = true;
    }//end isset if statement
try {
    if ($cycleGo == true) {
$stmtC = $db->prepare('INSERT INTO mytable (cycleNum, cycleStatus, processID) VALUES (:cycleNum, :cycleStatus, :processID)');
$stmtC->execute(array(':cycleNum' => $startCycleNum, ':cycleStatus' => $startCycleStatus, ':processID' => $idNum));
$cycleGo = false;
$newCycle = $db->lastInsertId();

    }
}//end try
catch (PDOException $ex) {
    echo '<h5>There was an error saving the new cycle.  Please try again.</h5>';
}//end catch

Any ideas would be greatly appreciated. I tried clearing my cache in Firefox to no avail.

EDIT: Code from submitting form getsteps.php

if ($stepNum != 'none') {
    echo '<form name="addNewForm" action="createcycleone?idNum='.$idNum.'stepNum='.$stepNum.'" method="post">

    <table width = "100%" id="formfields">';

    //form inputs

echo '<tr><td colspan="2">&nbsp;</td></tr>
<tr><td colspan="2" style="text-align:center"><input type="submit" value="Save and Create Cycle"></input></td></tr>
</table>
</form> ';
}

EDIT: Code from the php page calling getSteps.php to load the correct number of steps (fields)

//get the stepNum
if((isset($_GET['nid']))&&(isset($_GET['idNum']))){
$stepNum = $_GET['nid'];
$idNum = $_GET['idNum'];
}
  <form id="stepsForm" name="stepsForm">
      <table width ="100%" id="stepfield">

        <tr><td><strong>Number of Steps:</strong></td>
        <td><select name="getSteps" id="getSteps" onchange="$('#formContainer1').load('../files/createUAT/getSteps.php?nid='+this.value+'&idNum='+<?php print $idNum; ?>);">
        <option value="none">Select a Number</option>
        <option value="1">1</option>
        <option value="2">2</option>
        <option value="3">3</option>
        <option value="4">4</option>
        <option value="5">5</option>
        <option value="6">6</option>
        <option value="7">7</option>
        <option value="8">8</option>
    </select>
</td></tr></table>
</form>

<div id ="formContainer1" class="formContainer1">

</div>


Not sure if this is causing the issue, but change this...

'idNum='+<?php print $idNum; ?>

...to this..

'&idNum=<?php print $idNum; ?>'

That might be causing some cross-browser differences.