Jump to content

Recommended Posts

I have a very basic form (last name, first name, building, extension, email, request). Currently a user can fill out the form and submit and it will send an email as a work order for plant operations personnel and send a copy to the submitter. I want to use the ID number of the record as the work order number for user and operations personnel to track the issue. How can I get the ID number to add to the copy of the email going to the submitter? It seems it would have to connect to the database, get the next ID number, store it as a variable then do the rest of the script.

 

Any help is appreciated.

You need to store the record first, then get the id that was set when the record was stored.  For mysql, you want to use mysql_insert_id()/mysqli_insert_id();

 

If you try to get the next number first, you setup a race condition where multiple threads could go at the same time and get the same number as the next insert id, but only one of them would actually use that number when the records are inserted.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.