How To Password Protect A Webpage for Free
Once you have had a Blog, or website, for a while you begin to appreciate the value of your subscribers and sometimes want to share something special with them which you do not want the entire internet community to have access to. Perhaps, for example, you have developed a handy piece of software that you wish to share only with your subscribers, or you have a special selection of hand-picked Free Gifts for them.
One way around this would be to publish a simple “Free Gifts” download link in your newsletter. This can be ok but sometimes you may like the extra reassurance of password protecting the download page. You can then publish a new password in each newsletter with the reassurance that only current subscribers will then be able to access your protected webpage.
There are many programs available to create, and manage, Membership Areas on websites but these can be expensive, complex to set up and way over the top if all you want to do is password protect a single webpage.
I got around this problem for free by using a simple PHP script and thought I would share this script with you in case you also find it useful.
You can see the basic script in action by going to:
www.blog.ebook-download-shop.co.uk/Subscribersonly.php
and using the username “subscriber” and password “letmein”.
My “Subscribersonly.php” webapge begins with the following partial script:
<head>
<title>eBook Download Shop Newsletter Subscribers Only Area</title>
</head>
<body>
<?php
if (isset($_POST["entered_username"]) && isset($_POST["entered_password"])
&& ($_POST["entered_username"]==”$current_newsletter_username”)
&& ($_POST["entered_password"]==”$current_newsletter_password”))
{
?>
I then typed in all the HTML text from my private webpage followed by the second half of the script:
<?php
}
else
{
if (isset($_POST['entered_username']) || isset($_POST['entered_password']))
{
print “<p style=\”color: rgb(255, 0, 0);\” align=\”center\”>
<b>Oooops! Incorrect Login!</b></p>”;
}
print “<form method=\”post\”>
<h3 style=\”text-align: center;\”>Please login using the details from our latest newsletter:</h3>
<div style=\”text-align: center;\”>Username <input name=\”entered_username\” type=\”username\” size=\”16\” maxlength=\”16\”><br>
Password <input name=\”entered_password\” type=\”password\” size=\”16\” maxlength=\”16\”><br>
<br>
<input name=\”Login\” value=\”Login\” type=\”submit\”></div></form>”;
}
?>
<p> </p>
</body>
</html>
That is it. Simple and to the point. You can of course have a lot of fun fancying-up the appearance of the webpage as much as you desire but the above script is the basic guts which you need to password protect your page.
I hope you found this free Webapge Password Protect script useful. Unfortunately this Blog template sometimes messes up the formatting of my PHP code snippets but if you are one of my newsletter subscribers you can, as usual, download the files mentioned in this tutorial from the subscribers area of our website.













I have a similar post on setting up a password protected page that looks a lot easier to use, plus I even provide you with a .txt file with the correct formatting. All you do is save it as filename.php
http://www.mark-mcwilliams.com/password-protect-any-webpage-the-simple-way/
(I really hate how WordPress messes with the formatting!)
While all this is good, there can still sometimes be the hard way of telling people the login details.
Nice looking blog BTW!
Thanks
Mark
Hi Mark,
Thanks for being the first person to post a comment on my Blog. It is nice to know someone is actually reading my rambling thoughts. Thanks too for suggesting an alternative PHP login script. Yes; there are often many different solutions and different ways to solve any problem. Your comment is one of the great things I am looking forward to with the Blog; the ability to bounce ideas around, share thoughts and inspire and encourage others (including myself). Hopefully, when I start getting more than a couple of visitors a week, this Bog will become a lot more interactive.
The main reason I decided to write my own little PHP scripts for this Blog, rather than use scripts created by someone else, is because I am thinking of developing these scripts in future Newsletter / Bog Posts so I can show readers (when I actually get some!) stage-by-stage over a series of tutorials how, for example, to develop my simple Login script into something more complex with multiple login accounts and protecting multiple pages (my Subscribers Area is a “live” example of this).
This little Blog is still very much in it’s infancy and I am not sure how it will develop yet. It is supposed to be an account of my journey along the path to financial freedom but, as you can probably tell from my Posts, I seem to have become a bit distracted playing around with PHP scripts at the moment!
Yes; the way WordPress messes up formatting is a real pain. I am still learning how to drive this Blog at the moment so hope to sort it out soon but in the mean time my newsletter subscribers can download the scripts I mention from my Subscribers Area.
Thanks for the encouragement that you found my little Blog interesting. It is nice to know someone out there in “the big wide world” is actually reading what I write.
Ian.
LOL… there was me about to say wow, and be impressed, and I see Mark has beat me to it and given alternate examples….
Regardless - Just browsing your posts I found you’re giving a lot of useful info.
I hope more people find you and benefit from what you’re sharing Ian!
Guru’s might know how to better package stuff - but I’m a firm believer that a lot of little guys working together can provide a lot more and at better prices.
Thankfully you have found a marketer who should be called Guru - but never is due to him being just another little guy who has outsold a lot of guru’s - JT is well worth following and learning from!
Best Regards and keep up the good work Ian
Randy
http://www.MoreMonthly.com