| | |
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: 47
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: 557
Reputation:
Solved Threads: 64
0
#2 Nov 4th, 2009
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: 557
Reputation:
Solved Threads: 64
0
#4 Nov 4th, 2009
•
•
•
•
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; Nov 4th, 2009 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: 557
Reputation:
Solved Threads: 64
0
#6 Nov 4th, 2009
"The discipline of writing something down is the first step towards making it happen."
follow me on twitter
follow me on twitter
0
#7 Nov 4th, 2009
•
•
•
•
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: 47
Reputation:
Solved Threads: 0
0
#8 Nov 4th, 2009
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: 557
Reputation:
Solved Threads: 64
0
#9 Nov 4th, 2009
•
•
•
•
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: 47
Reputation:
Solved Threads: 0
0
#10 Nov 4th, 2009
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; Nov 5th, 2009 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 |
Tag cloud for JavaScript / DHTML / AJAX
ajax ajaxcode ajaxhelp animate api automatically beta boarder box bug calendar card checkbox child class column cookies createrange() css cursor dependent disablefirebug dom download dropdown editor element engine error events explorer ext file firehose flash form forms game google gwt html htmlform ie8 iframe image() images internet java javascript jawascriptruntimeerror jquery jsf jsfile jump math matrixcaptcha microsoft mimic mp3 mysql object offline onmouseoutdivproblem onreadystatechange parent passing pdf php player post problem progressbar rated rating regex runtime scroll search select session shopping size sql star stars stretch text textarea twitter validation w3c web website window windowofwords windowsxp wysiwyg xml xspf \n





