In my opinion, the code is decent from a functional perspective. That is, it looks like it does what it's supposed to do. For PHP syntax, I think you have a good understanding of passing variables from your form to your script, you have a good understanding of arrays (though I might do it differently in fewer steps - but you'll get that with experience). You have a good understanding of making it work with a database. These are far more skills than lots of beginners who come to this site looking for help.
Here's my criticism: The code is vulnerable to a security flaw called SQL injection. I'll describe it briefly since it's been discussed a thousand times before in this forum and a million times before all over the Internet.
Basically, you are too trusting of the data that is passed in from the user. In theory, people will only use the form that you supply them, they will fill in the fields with simple data, and your script will work fine. In practice, hackers will build their own forms and post to your script and they will pass dangerous and destructive data to your script. Consider the following example:
$name = $_POST['name']; // this receives the data from the name field in the form
$query = "insert into users (name) values ('$name');
Theoretically, this should just add another name to the database. But what if someone enters the following as their name:
Bob'); delete from users where name='Sue';
Now $query will have the following value:
insert into users (name) values ('Bob'); delete from users where name='Sue';')
And when you perform that command on your database, it will add the name Bob but delete everyone named Sue. With a little creativity, you could change everyone's password, delete everyone's account, etc.
I guess this is what people mean when they say, "I know enough PHP to be dangerous". Your skills are good enough that you can create a site that could backfire horribly! 🙂 Keep practicing, though, you're on the right track.