| | |
How to Password protect files / sections on web page ?
Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Oct 2007
Posts: 37
Reputation:
Solved Threads: 0
Hi,
I'm sorry in advance if this is the wrong section.
I wanted to know is it possible to password protect some files in web page ?
For example, If someone wants to download file, browsers requests password(one for all visitors), idea is that some files and/or sections of web site is accessible to those who know the password..
Any advice , help much appreciated !
I'm sorry in advance if this is the wrong section.
I wanted to know is it possible to password protect some files in web page ?
For example, If someone wants to download file, browsers requests password(one for all visitors), idea is that some files and/or sections of web site is accessible to those who know the password..
Any advice , help much appreciated !
•
•
Join Date: Sep 2009
Posts: 525
Reputation:
Solved Threads: 61
0
#2 24 Days Ago
try to code something like this -
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
function validate() { var truePassword = 'test'; var password = prompt('Enter the password',''); alert(">>"+password+">>"); if(password !='' && password !=null) { if(password != truePassword) { alert("You don't have download permissin for this"); } }else { alert("Enter the password"); } }
"The discipline of writing something down is the first step towards making it happen."
follow me on twitter
follow me on twitter
•
•
Join Date: Sep 2009
Posts: 525
Reputation:
Solved Threads: 61
0
#4 24 Days Ago
•
•
•
•
where in code should I put this php ?
is it for single file or for section in web page ?

It may work against the single link which will prevent the download without entering the password
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
function validate() { var truePassword = 'test'; var password = prompt('Enter the password',''); //alert(">>"+password+">>"); if(password !='' && password !=null) { if(password != truePassword) { alert("You don't have download permissin for this"); return false; } }else { alert("Enter the password"); return false; } }
Last edited by network18; 24 Days Ago at 6:34 am. Reason: modified function
"The discipline of writing something down is the first step towards making it happen."
follow me on twitter
follow me on twitter
•
•
Join Date: Sep 2009
Posts: 525
Reputation:
Solved Threads: 61
0
#6 24 Days Ago
"The discipline of writing something down is the first step towards making it happen."
follow me on twitter
follow me on twitter
0
#7 24 Days Ago
•
•
•
•
call this function on click of the link, from where you download the pdf file.
Another way would be to put the pdf in a separate folder on the server, and password protect it (using your cPanel, htaccess, or whatever you're using).
"If it is NOT source, it is NOT software."
-- NASA
-- NASA
•
•
Join Date: Oct 2007
Posts: 37
Reputation:
Solved Threads: 0
0
#8 24 Days Ago
Do I call function like this ?
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
<a href="faili/materiali/brosuras/maskesana.pdf" target="_blank" onclick="function name">
•
•
Join Date: Sep 2009
Posts: 525
Reputation:
Solved Threads: 61
0
#9 24 Days Ago
•
•
•
•
Do I call function like this ?
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
<a href="faili/materiali/brosuras/maskesana.pdf" target="_blank" onclick="function name">
"The discipline of writing something down is the first step towards making it happen."
follow me on twitter
follow me on twitter
•
•
Join Date: Oct 2007
Posts: 37
Reputation:
Solved Threads: 0
0
#10 24 Days Ago
It doesn't seem to work:
I wrapped code you provided in js tags (otherwise code showed as plain text on page)
Edited link like this
I wrapped code you provided in js tags (otherwise code showed as plain text on page)
Edited link like this
<a href="faili/materiali/brosuras/maskesana.pdf" target="_blank" onclick="function validate"> Last edited by peter_budo; 23 Days Ago at 7:08 pm. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks)
![]() |
Similar Threads
- From Web Page, Download a Folder containing Files To Client PC (VB.NET)
- listing files on web page (VB.NET)
- Password Protect (JavaScript / DHTML / AJAX)
- How do I Password protect a web-page (Windows NT / 2000 / XP)
- How do i Password protect all my asp.net pages on my website (ASP.NET)
- igoogle style window drag & drop in diferent sections of a web page (JavaScript / DHTML / AJAX)
- Code Snippet: PHP Session Management & Password Protect class (PHP)
- password protecting files on another HD (Windows NT / 2000 / XP)
- unable to load windows update web page (Viruses, Spyware and other Nasties)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: onClick code dont now how to use.
- Next Thread: Warning Message on Browser Close
| Thread Tools | Search this Thread |
acid2 ajax ajaxexample ajaxjspservlets array beta browser captchaformproblem cart checkbox child class close codes column css date debugger decimal dependent design disablefirebug dom download editor element embed engine enter error events explorer ext file firefox focus form forms frameworks getselection google gwt gxt hiddenvalue highlightedword hint html ie7 ie8 iframe index internet java javascript javascripthelp2020 jquery jsf jsfile jsp jump libcurl listbox maps masterpage math media menu mp4 object onmouseoutdivproblem onmouseover onreadystatechange parent paypal pdf php position post problem programming prototype redirect runtime safari scale scriptlets scroll search security select shopping size software toggle unicode w3c web windowofwords wysiwyg \n





