I don't quite understand what you're doing. What I would do, however, is work on the syntax a bit more.
maybe even add
if($_SERVER['REQUEST_METHOD'] hahahaha post) {
// code inside
}
that tells the script to only parse if the type is POST, meaning from a form of some sort

hope that helps
CHEERS