WordPress search input in database, to edit information via form and update the database

I have a couple of observations/suggestions that might help.

  1. You should use the GET method instead of the POST for the search form, so that you can use the POST method in your update form.

  2. Update query should not be the part of the loop that is generating the update form. I recommend moving the update code to the top of the file and put it under the condition of available core fields.

  3. There is no field with p_id name in your update form, so include a hidden field for that and update the database based on that field’s value.

  4. Also make sure all the generated markup appears in the body tag.

Hopefully, you will have a much better code structure after making these changes and you will also be able to nail down any remaining issues.

Good luck