Is it safe to connect to another server to send form data?
If you clear your required flow then a better solution can be suggested.

It is not a good practice to perform at page--path.tpl.php

Use hook_init in your custom module and check arg(1) to confirm your path.

Data can also be posted using drupal_http_request($server_url, $headers, 'POST', $data);