I'm guessing you can't include the footers and such because when you don't find the card, you execute a [man]die/man command.
Also, a couple things to note:
1.) You're using $HTTP*VARS which is deprecated. Use $POST and $GET now
2.) You check whether items are sent via POST or GET with preference to post. This poses a possible security issue in someone sending malicious code through the URL to your program. Try limiting the input to POST and not checking for anything via the URL.
3.) If you insist on checking for URL and POST variables, you can make it easier in one of two ways:
3.a) Make use of the $REQUEST array
3.b) Figure out which one is not empty, and then put that array's contents into a new array:
$submitted_contents = (!empty($_POST) && isset($_POST)) ? $_POST : $_GET;
Also, when posting code, please use the VBCode items:
For PHP code: [php]<?php YOUR PHP CODE; ?>[/php]
For HTML: [html]YOUR HTML CODE[/html]
For All other code: [code]YOUR CODE[/code]