the problem with the image name not getting stored to the database is because of code order.
the update code is at lines 4 - 44.
the image upload code is at lines 88 - 118
The image upload code needs to be moved so that it comes before the code to update the record.
The problem with the ID being set to 0 is happening because you have bound the prod_id column in the update record to a prod_id form element that does not exist.
in the update, prod_id column should not be bound to anything so that it will not get changed.