Simple Password Protection

  babybell 23:37 31 Jan 2006

I have setup a website for my local rugby team and they wish to have a page that shows the top try scorers and other stats. However, we wish this page to be protected from any other clubs that may visit the site because they can sus out who to watch in a match and put us at a disadvantage. It only needs to be one password that i will tell team members so no individual passwords will be required. Does anyone know of a little cgi script that will lock this one webpage and prompt for the password?

  Forum Editor 00:07 01 Feb 2006

is that they are ridiculously easy to break, or the visitor can see the password in the page's source code.

On the other hand, some of the better solutions can be a tad tricky to set up, and are probably overkill for what you want.

click here for something that might suit you. It's pretty secure, easy to install, and cheap.

  Lord Isleworth 10:59 01 Feb 2006

This will do exactly what you need. quite easy to follow hpefully.
Webmania my host sent me this info *£20 a year hosting - bargain and great support* First thing you need to do is create .htpasswd file in the folder which you want to be password protected. You can create it in your root directory that is home directory if you want to password protect your site. In your case create a folder called stats and store it here. This file contains the list of username and password (which is encrypted) for those whom you want to have access.
Use this tool to generate the lines you need to place in .htpasswd file.
click here
So you would put just one username and password eg rugby and try as the password (like what I did there)

Copy and paste the code generated in the .htpasswd file and upload this file as ASCII and not BINARY in the folder you want to protect.
Set the file permissions to 644. You can set the permission to your file via ftp by right click on file/folder>> Operations >> FTP commands >> CHMOD.
Or you can also do this via shell by using chmod command Syntax : chmod 644 filename/foldername.

This worked fine, but you have to ftp the files across to set the permissions.
Hope this is useful to you.

  harristweed 13:48 01 Feb 2006

1. put this code immeadiatly under the <body> tag of your page
2. change the line "$user_password="password"; to $user_password="YOUR PASS WORD HERE";
3- rename your page from page_name.htm
to page_name.php

<form <?php echo " ACTION=\"$_SERVER[PHP_SELF]\" METHOD=POST"; ?>>
if($password!==$user_password or empty($password))
echo "<table width=\"50%\" border=\"0\" align=\"center\" cellpadding=\"5\" cellspacing=\"0\">";
echo "<form action=\"$_SERVER[PHP_SELF]\" method=\"post\">\n";
echo "<td colspan=\"2\" class=\"normbr\"><div align=\"center\">"; // check if password correct or set
if (isset($password))
echo " Password Incorrect - please try again ";
<tr> <td class="norm"><div align="center">Please enter your password.</div></td><td><input name="pass" class="norm" type="password" id="password"></td></tr>
<tr><td colspan = "2"><div align="center"><input type="submit" name="Submit1" class="norm" value="Submit"></div></td></tr></form>

And thats it.

No 20 quid

no chmod

no problem!

  Lord Isleworth 14:42 01 Feb 2006

harristweed, you misunderstand I didn't have to pay for that info above, I pay £20 a year to host sites with them, that's what I meant and the support is quality and free

This thread is now locked and can not be replied to.

Elsewhere on IDG sites

Best phone camera 2017

Stunning new film posters by Hattie Stewart, Joe Cruz & more

iPad Pro 10.5in (2017) review

28 astuces pour profiter au mieux de votre iPhone