I will try to put this as simple as possible. I have a section of code that is using session id to locate table row with same id to update and view database table info. How ever i would like the form to display and when user hits button labeled make changes or update if the table row does not exist with session id would like for the code to create and insert data and then next time only update?
for example

user is on a page that asks them what they would like to do they click on a link then are redirected to another page. on this page they see a form to fill out and when they hit enter or click update button it inserts data to table with session id so that the next time when they come back to this form they can see what they put init last time and can make updates to it with out the database making a duplicate entry

not sure if i should be using ' on duplicate ' or ' if not exists ' looking for something search online tried various options and nothing seems to work.