That's kind of an off approach.
What you want to do is define your page with a link that 'onclick' calls your window open script.
1. Build an HTML page and replace userid with %USERID% - ni our example it will be template.htm
2. Build a PHP page that has available the user's id, in a SESSION variable, or POST - anything you like. If it were stored in a SESSION array it would look like this:
session_name( 'somename' );
$fp = str_replace( '%USERID%', $_SESSION['userid'], implode( '', file( 'template.html' ) );
this way, the php file reads the unparsed template, replaces %USERID% with the actual user id, and then echoes the result.