Help me with this pls!

hi guys!

im creating a web site, and i need when any user want download something of my page.

before download the file, appeear a window that say

( please enter your mail:Textfiled_, if you want download the file you much enter your mail. )

if the user write its email, i want that the mail that him introduced save in a file called. ( mails.txt ) and the user can download the file too. like. download1.zip

thanks!