944,028 Members | Top Members by Rank

Ad:
You are currently viewing page 2 of this multi-page discussion thread; Jump to the first page
Nov 4th, 2009
0
Re: How to Password protect files / sections on web page ?
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. <a href="faili/materiali/brosuras/maskesana.pdf" target="_blank" onclick="validate();">
Sponsor
Featured Poster
Reputation Points: 556
Solved Threads: 731
Bite my shiny metal ass!
pritaeas is offline Offline
4,188 posts
since Jul 2006
Nov 4th, 2009
0
Re: How to Password protect files / sections on web page ?
Leave it, it wont work.Here is one more logic -
-redirect the user to another php page when he tries to download the pdf, adn check his username/password there.
-if username/password are right just get him back to the previous page or else directly exit or do whatever you wish.
Reputation Points: 29
Solved Threads: 76
Practically a Master Poster
network18 is offline Offline
616 posts
since Sep 2009
Nov 4th, 2009
0
Re: How to Password protect files / sections on web page ?
There are 2 ways to securely do this. The first one is to make the download dir inaccessible without password (this is as said done in htaccess e.l. and not in you code). The other one is to put the file outside of you public_html-folder (http_root o.l. it might be called on a winserver) and use a script/program like php or C# to read the file and output it to the response-stream if the password is correct.
Reputation Points: 15
Solved Threads: 10
Junior Poster in Training
Alxandr is offline Offline
73 posts
since May 2009
Nov 4th, 2009
0
Re: How to Password protect files / sections on web page ?
I found out about htaccess few hours ago. Now I know how can I password protect a single html page. which was one of the things I needed.

But how can I password protect single file or better yet <a href> tag ? I don't know much about php etc. so I wanted to ask in this forum for some help, maybe someone know some tutorials regarding this ..
Reputation Points: 10
Solved Threads: 0
Junior Poster
wonderland is offline Offline
108 posts
since Oct 2007
Nov 4th, 2009
0
Re: How to Password protect files / sections on web page ?
Click to Expand / Collapse  Quote originally posted by wonderland ...
I found out about htaccess few hours ago. Now I know how can I password protect a single html page. which was one of the things I needed.

But how can I password protect single file or better yet <a href> tag ? I don't know much about php etc. so I wanted to ask in this forum for some help, maybe someone know some tutorials regarding this ..
Password-protecting a single a-href doesn't make sense. What does is to password-protect the file that the a-href points to. And if you already know how to password-protect a html-file my guess is that it shouldn't be much of a difference in password-protecting a pdf-file or a img-file etc.
Reputation Points: 15
Solved Threads: 10
Junior Poster in Training
Alxandr is offline Offline
73 posts
since May 2009
Nov 4th, 2009
0
Re: How to Password protect files / sections on web page ?
Thanks, everything works great, I don't know why, but somehow I imagined this would be much harder :p.

Got 1 question though:

when I clicked on .pdf link (without .htaccess) it opened in a new tab/window. Now when I have .htaccess, browser opens new tab and asks for authorization , which is all great, but if i press cancel I get Authorization Required error page. Is it possible to somehow get redirected back to the page from which I opened that .pdf instead of error page ?
Last edited by wonderland; Nov 4th, 2009 at 7:50 pm.
Reputation Points: 10
Solved Threads: 0
Junior Poster
wonderland is offline Offline
108 posts
since Oct 2007
Nov 4th, 2009
0
Re: How to Password protect files / sections on web page ?
I'm not shure about that. That's about server-settings, and not programming (.htaccess is too actually server-settings, but I'm not that familiar with it).
Reputation Points: 15
Solved Threads: 10
Junior Poster in Training
Alxandr is offline Offline
73 posts
since May 2009

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in JavaScript / DHTML / AJAX Forum Timeline: onClick code dont now how to use.
Next Thread in JavaScript / DHTML / AJAX Forum Timeline: Warning Message on Browser Close





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC