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
2 1419
I think you need better design because every time the page executes (such as using the Back button) the page executes again (sending the value to DB once more)
If this is suppose to add dynamic fields, I would do it with Ajax.
If this is more resume Edition, I would do this:
With JavaScript I'd insert a set of fields (row) to my table (let's say the Education Section) and when the user is done editing the resume, clicking "Save" would write it to the DB.
Let me know what the use case is, I'm not sure at this point why you're doing what you're doing.
Dan
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Reply Via Newsgroup |
last post by:
Folks,
Say I have a table, ten columns, ten rows - Each with a word in it. I want
to change the values of some/all of the cells in the table via a hyperlink.
How do I reference each cell and...
|
by: Gunnar Kristiansen |
last post by:
Hi!
I have a form page which I am using as a frontend for my MySql database
(for writing news). I do miss the functionality of a few buttons that
could help me insert HTML tags etc, into my main...
|
by: mfrsousa |
last post by:
hi there,
i have a huge large text file (350.000 lines) that i want to import to
a MS Acccess Database, of course i don't want to use Access, but do it
with C#.
i already have tried the...
|
by: Xah Lee |
last post by:
Text Processing with Emacs Lisp
Xah Lee, 2007-10-29
This page gives a outline of how to use emacs lisp to do text
processing, using a specific real-world problem as example. If you
don't know...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |