我真的被困在这里了。我有一个在 Firefox 上运行两次的插入语句,但(正确地)在 IE 中只运行一次
什么可能导致 Firefox 运行两次插入语句?它只运行此查询两次,而不是页面上的其他查询。除了我在下面发布的内容之外,我还注释掉了所有其他代码,它仍然在 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
任何想法将不胜感激。我尝试在 Firefox 中清除缓存无济于事。
编辑:提交表单 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"> </td></tr>
<tr><td colspan="2" style="text-align:center"><input type="submit" value="Save and Create Cycle"></input></td></tr>
</table>
</form> ';
}
编辑:调用 getSteps.php 的 php 页面中的代码以加载正确数量的步骤(字段)
//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>