Where is $link_url ever defined? Or $link_name?
Change all of those variables that reference HTML elements POST'ed from a form to their proper form: $_POST['element_name'].
For more information on this $POST superglobal array (and others - such as $GET), see this manual page: [man]variables.predefined[/man].
As to what the problem is, this script relies on register_globals being on. This directive, however, has long ago been deprecated and proven to be a security exploit (thus any sensible server admin will have it disabled).
EDIT: Furthermore, these lines:
global $filename;
are relying on the same directive. Once you switch that code over to use $POST['filename'] instead, you will no longer need those [man]global[/man]; lines. Why? As I said before, the $POST array (and its friends) are superglobals, or available in every variable scope.