PHP bug form, last page viewed code

Hello,

I am creating a php email form for users to contact me regarding bugs and additions. They will be clicking on a link in the template section of a page that will popup a window with the form. I want the code to include the page they were viewing when they clicked the bug report link. Is this possible when it is in the template section? Will it be an issue that I am having a popup window? And what is the code to display the last page viewed. Any help would be greatly appreciated.

Thanks,

Tom