Learn from this, and like DaveMaxwell intimates get used to using some debug as you work along.
If you have a script which is going to be dependent upon incoming variables such as GET or POST then get used to echoing them out onto the page at the top of your script.
// comment this out or remove it when you have affirmed that the incoming
// vars actually meet your expectation
echo '<hr />';
Do the same for $_POST too ..
Get into the swing of having PHP prove to you that what you think should be happening matches what PHP is doing.