QuintusSmit
asked on
Get id of newly created database entry
Hi
I am wrinting a registration system for my students in php. I have a form that gets submited with all the info but I want certain things to get registered in the background based on selections in the form. I cant always trust that student numbers will be unique so I want to retrieve the unique id no created for the person by the mysql db.
Logic says submit the user to the db and then immediatly query the id to a variable once created. My problem is what if there is a duplicate name or student number already. Should I
just check for that before submitting or is there a better way to do this.
Tx
Quintus
I am wrinting a registration system for my students in php. I have a form that gets submited with all the info but I want certain things to get registered in the background based on selections in the form. I cant always trust that student numbers will be unique so I want to retrieve the unique id no created for the person by the mysql db.
Logic says submit the user to the db and then immediatly query the id to a variable once created. My problem is what if there is a duplicate name or student number already. Should I
just check for that before submitting or is there a better way to do this.
Tx
Quintus
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Dave - could you pls have a look at this question
https://www.experts-exchange.com/questions/27382125/mysql-insert-id-gives-a-0-return.html
tx
https://www.experts-exchange.com/questions/27382125/mysql-insert-id-gives-a-0-return.html
tx
ASKER