Unique ID for db entry


Actually, I am looking for a solution to a problem,

mysql_insert_id will only work if it passed to the processing page and then system will be able to update the record;

is there any way to store the mysql_insert_id even if the page is refreshed.

What I want to achieve is to update database row which the user have previously entered even if the user refreshes the page;


Well what mysql_insert_id does is - Get the ID generated in the last query.

So you want to update the ID of the respective row every time the user refreshes and display it via mysql_insert_id?

What is the ID value in your DB table? is it set to auto_increment?

Thanks Wackyjoe,

I guess, I haven’t explained it well, leme try again,

Lets suppose I am a user visited a page
and filled a form and the data is submitted and inserted into database, now each time form is updated; the db entry will be updated as well by the help of mysql_insert_id;

after the first entry to the database, if the user refreshes the page; and try to submit the data again,data should be stored in same row rather than inserting new row in the db.

yes ID is auto_increment.

yes, want to update the same row even if the page is refreshed.

Thanks, solved,

if(empty($_SESSION['id'])) {
 $_SESSION['id'] = @mysql_insert_id(); }
 else {
mysql update query where id = $_session['id']; }