The challenge with PHP is that you need to understand HTML, PHP and SQL to get anythign useful done and if you are shaky on any of that it is hell to track down problems. Your HTML is shaky and that suggests you might need some more time on that before you move on but having said that your code looks fine apart from the issue already mentioned by Barand. It should work once you remove the if statement.
If you want to have another go here is a page I wrote on the subject for 16 year olds. The site was written to be followed start to end but I think the page makes sense on it's own (especially if you follow the link to the place I explained how to create a form.
https://www.yourwebskills.com/page.php?page=124