Remove lines 10-15
That is leftover from the previous version and it is what is causing the warning message.
Move the update code above the insert and remove the redirect. Right now the redirect will happen after the insert and the update code would never run.