You need to set php's error_reporting to E_ALL and display_errors to ON, preferably in the php.ini on your system, so that php will help you by reporting and displaying all the errors it detects.
You have two mistakes in the first piece of code that you could find based on the php errors you would be getting. Not going to specifically list the problems, because you need to learn how to debug your code, by making use of php/database errors you get, and determining where problems are at by finding where your code/data are dong what you expect and where they are not.
Next, you should use a post method form when inserting, updating, or deleting data. This is more than just a web convention, it is so that search engines indexing your site won't cause data to be inadvertently created, modified, or deleted. Search engines will only make get requests to your pages. You will also eventually need to add a user permission system to control who has permission to insert, update, or delete data.
Once you switch to use a post method form, your form processing code needs to -
1) Detect that a post method form was submitted.
2) Trim all the input data. This will allow you to detect if all white-space characters were submitted.
3) If the form processing code handles more than one 'action' (insert, update, or delete) it needs to detect which action was submitted (a switch/case statement is commonly used.)
4) Validate the input data. If the expected/required input data for any particular action isn't valid, there's no point in using it in the rest of the code. If you store validation errors in a php array variable, the array is also an error flag. if the array is empty, there are no errors. If the array is not empty, there are errors. To display the error(s) on the web page, when you re-display the form, just loop over the array holding the errors and output each one.
5) If there are no validation errors, use the submitted data.