Can you be a little more specific about what exactly isn't working? Are you getting a "500 Internal Server Error"? If so, do you get an error message in your server's error logs?
Maybe the problem is that you're not printing an HTTP header? Try adding this before the last print line: