I'm not sure I fully understand your requirement but I've modified your code.
There is now a button that says 'Prepare Badge', this opens a window with the badge preview inside and a button that allows the javascript window.print function to be used to print the contents of the popup.
with PHP I personally prefer to create PDF documents, I find ezPDF quite easy to use.
PHP Code:
<SCRIPT LANGUAGE="JavaScript">
function openindex()
{
OpenWindow=window.open("", "newwin", "height=250, width=250,toolbar=no,scrollbars="+scroll+",menubar=no");
OpenWindow.document.write("<TITLE>Title Goes Here</TITLE>");
OpenWindow.document.write("<BODY BGCOLOR=pink>");
OpenWindow.document.write("<h1>Test!</h1>");
OpenWindow.document.write("Your Photograph is : <?php echo $var1; ?><br>");
OpenWindow.document.write("Your Name is : <?php echo $var2; ?><br>");
OpenWindow.document.write("Your Title is : <?php echo $var3; ?><br>");
OpenWindow.document.write("Your ID is : <?php echo $var4; ?><br>");
OpenWindow.document.write("<br>");
OpenWindow.document.write("<br>");
OpenWindow.document.write('<form id="printMe" name="printMe"> <input type="button" name="print" onClick="window.print()" value="Print Badge"> </form><br>');
OpenWindow.document.write("</BODY>");
OpenWindow.document.write("</HTML>");
OpenWindow.document.close()
self.name="main"
}
</SCRIPT>
<table width="280"><tr><td valign="center">
<img src="http://www.domain.com/media/images/badgelogo.gif"><br>
<?
$var1="your photo";
$var2="your name";
$var3="Title";
$var4="ID";
?>
<?= $_GET["PrimPhoto"]; ?><br>
<?= $_GET["Name"]; ?><br>
<?= $_GET["Title"]; ?><br>
ID# <?= $_GET["ID"]; ?><br>
Member Since
<?= $_GET["DateReg"]; ?>
</div><br>
<form id="printMe" name="printMe"> <input type="button"
name="printMe" onClick="openindex()" value="Prepare Badge"> </form>
</td></tr></table></center>
Bookmarks