Ruky no point in having a code to allow download, on your Hosting we have what is called PASSWORD PROTECTED DIRECTORY thats if you using Linux server, create a folder where you want to put files they want to download and create a username and password for it. then if any of your clients try to download it's will alert them of putting in Username and Password just somthing like this,
http://www.smartsoft-ng.com/ebook/ Username : free Password : ebook lol i have a PHP/MYSQL book there you can download it lol
=================================================================================
Secondly you can have a two pages, 1 for username and password to login then 2 the page where user can download after login name is kind of succesfull using PHP/MYSQL