I think you have a register_globals issue here. Your script is expecting POST and GET variables to be accessible from a global point of view.
Since PHP 4.2 (?) and certainly in PHP 5, register_globals directive is set to off by default. This means GET and POST variables (among others) are not accessible by just referencing the variable name. Instead, the relevant variables are put in the $GET and $POST associative arrays.
So line 2 of your code:-
if(isset($action))
needs to become
if(isset($_GET['action']))
or
if(isset($_POST['action']))
if your form uses POST method.
The other POST/GET variables in your script will also need changing in similar fashion.
Hope this helps.