I have some downloadable documents (PDF) on my website for visitors to download. But I want to collect their personal information (name, email etc) before they are able to doanload them. Can anyone tell me if there's a simple way of doing this?

Dani AI

Generated

A practical, low-risk way to collect name/email before a PDF download on an ASP host, building on and and clarifying ’s point about client-side limits:

  1. Public form (POST) that includes a document identifier. Client-side validation is fine for UX but never trusted for security.
  2. Server handler (ASP/ASP.NET): validate inputs server-side, save a minimal record (name, email, doc_id, timestamp, IP) using parameterized queries, then generate a cryptographically strong one‑time token (store token, doc_id, expiry, used_flag).
  3. Download endpoint (not a direct file link): accept a token, verify it against the DB (expiry, doc match, not used), stream the file from outside the webroot and set Content-Disposition: attachment. Mark token used or expire it after first use.
  4. Optional: send the token link by email to confirm the address. Add CAPTCHA/rate limits to reduce automated harvesting.

Security and privacy notes: always serve the form and download over HTTPS, keep PII to the minimum needed, publish a short privacy/retention statement, and implement a reasonable data-retention policy (delete old records). For legal compliance see general GDPR guidance at gdpr.eu. For secure access-control and session handling, OWASP resources are useful: Access Control Cheat Sheet.

Troubleshooting tips: common failures come from wrong file paths/permissions, token not persisting due to DB/encoding issues, clock skew making tokens appear expired, or missing headers that force download. Confirm whether the server runs classic ASP or ASP.NET so sample code can match the platform. For streaming/attachment best practices in ASP.NET, see Microsoft’s file-results guidance: .

Recommended Answers

All 10 Replies

You can do simple html form, however that can be cheated. So you need to look in some server side technology with ability to talk to database like PHP, ASP, JSP or AJAX (not exactly server side but can chat with database)

Thanks Peter - I'm a newbie to this, can you talk me through it or point me to some code I can use???? Thanks :-)

Depends what you want to do:

  • simple form with html
  • html with JavaScript validation
  • use PHP/ASP/JSP/AJAX

restrict your user to download only after providing his/her information...
this is done by sessions concept in php or provide login form....

I think our server supports ASP or could go for HTML and JavaScript - I'll go with whatever you suggest!!

restrict your user to download only after providing his/her information...
this is done by sessions concept in php or provide login form....

PHP is not only technology with sessions :D I can do it nicely in JSP ;)

I think our server supports ASP or could go for HTML and JavaScript - I'll go with whatever you suggest!!

Find out what your server supports, so you can take advantage of technology

I've checked with IT and as I thought the server supports ASP or I can script HTML with JavaScript - can you help?

JavaScript can NOT collect user information, because it runs on the user's computer, not your server.

I did suggest JavaScript as way to validate form in the case if Ems do not want to go into other options.
ASP is not my speciality but you should be able to work out your requirements on these tutorials

That's great, thanks for your help :-)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.