There are a lot of things wrong, first you didn't named your html form
tags, and secondly you didn't use the $key variable in your php code to
modify your query. You need learn about basic form interactions. I also
strongly suggest you to look into MVC, having a sql connection just 10 lines above the
template code is really bad.