 | Member | | Join Date: Jun 2007
Posts: 75
| |
Hey, I have a simple web app that requires the user to click a text link to add a section to the form. As you will see from the following code (PHP/mySQL), the link inserts a row into the database table. The problem is that, during testing, sometimes when I click the link, two rows are added instead of only one. I only want one row to be added. Could you please help me figure out my bug? - // Insert and delete actions for Education, Work Experiences, and References
-
if($_GET['action']=="insertEdu" && $_GET['checkId'] == $_SESSION['usrId'] && !isset($_SESSION['keyEdu']))
-
{
-
-
$sqlInsertStatementEdu ="INSERT INTO edu5000 (eduId, eduUsrId, eduName, eduCity, eduState, eduStatus, eduStartDte, eduEndDte, eduDegree, eduMajor, eduMinor, eduExtra, eduLastChgUsr, eduLastChgDte) VALUES (NULL , '".$_SESSION['usrId']."', NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , '".$_SESSION['usrEmail']."', now())"; //PROBLEM! INSERTING MULTIPLE ROWS SOMETIMES, NEXT ADJUST edu fields, NEXT adjust work exp, NEXT references, NEXT non-textbox controls
-
$resultEdu0 = mysql_query($sqlInsertStatementEdu); // Insert row into edu
-
-
if (!$resultEdu0) {
-
print('Sorry, database error. Please try again later. If problem persists, contact administrator (reference error 2784)');
-
} else {
-
$_SESSION['keyEdu'] = mysql_insert_id(); //sets new edu entry session key to prevent multiple new rows
-
}
-
}
and the body work... - <div><a href="resume.php?action=insertEdu&checkId='.$_SESSION['usrId'].'">(+ add education entry)</a></div>unset($_SESSION["keyEdu"]);//END EDUCATION
|