Hello all,
What is the simplest way to password protect a page on a website? I have a client that wants to post a resume, but wants that page viewable by only those that have the password.
Thanks in advance!
| SitePoint Sponsor |
Hello all,
What is the simplest way to password protect a page on a website? I have a client that wants to post a resume, but wants that page viewable by only those that have the password.
Thanks in advance!

There are scripts already for that. Just search in google for password protection scripts in the programming language you choose. Many of them check that the password is correct by comparing it with the value store in a database. If what he wants is just minimal protection, you could create your own script:
This assumes that you have a form like thisCode:$passWord="whatever"; if ($POST_['passwordField']=="whatever") { header('location:http://www.domain.com/whateverpage.htm'); }
Of course, you don't need to use PHP, you can use whatever you want.Code:<form name="myPassword" method="post"> <label for="passwordField">your password here</label><input type="password" name="passwordField" /> </form>
Also, be aware that the protection this provides is minimal, almost non-existant
Last edited by molona; Oct 18, 2008 at 07:08. Reason: correcting misspelling
Before asking, do a search... if you don't find the answer, then ask
The purpose of this forum is to help others in the community, that's why it's called Sitepoint and not Linkpoint.
SP Guidelines - No fluff.
Thinking Web: Voices of the Community - The Community Book

I just uploaded my resume as a passowrd protected PDF.
Stephen J Chapman
javascriptexample.net, Book Reviews, follow me on Twitter
HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
<input name="html5" type="text" required pattern="^$">
This line
if ($POST_['passwordField']="whatever") {
Should be:
if ($POST_['passwordField']=="whatever") {
And this line
header('location: ....')
Should be
header('location: ....');

Thank you for the correction Inexplicit. I always write in a hurryYou are quite right, for comparision purposes, I should have used == and it is always good practice to place the ; at the end of the line, even if it is the very last.
Before asking, do a search... if you don't find the answer, then ask
The purpose of this forum is to help others in the community, that's why it's called Sitepoint and not Linkpoint.
SP Guidelines - No fluff.
Thinking Web: Voices of the Community - The Community Book
Bookmarks