How to password protect a website section

Can't find a suitable category? Post it here!!

Moderators: nickj, Lady of Mystery, Mandrake, bananafish, support

How to password protect a website section

Postby Stephen Ward » Jul 31st, '05, 13:49



Does anyone know of a cheap or free way to put a password protected section onto a website?

Stephen Ward
Veteran Member
 
Posts: 5848
Joined: Mar 23rd, '05, 16:21
Location: Lowestoft, UK (44:CP)

Re: How to password protect a website section

Postby DaveOrdref » Jul 31st, '05, 14:24

stephenmagic wrote:Does anyone know of a cheap or free way to put a password protected section onto a website?


PHP?

Code: Select all
<?php
if ($_GET['p'] == 1) {
if ($_POST['pass'] == "PASSWORD") {//PASSWORD is the password (maybe you should change it)
echo "<H1>PASSWORD PROTECTED PAGE</H1>";//in between these speechmarks put the html of the password protected page
}
else {
echo "<H1>WRONG!!!!!!</H1>";//likewise - html of the page if they get it wrong
}
}
else {
echo "<FORM NAME="form" METHOD="POST" ACTION="".$_SERVER['SCRIPT_NAME']."?p=1"><INPUT TYPE="password" NAME="pass"></INPUT><BR><INPUT TYPE="SUBMIT"></INPUT></FORM>";//html of the page where you input password
}
?>
<!-- maybe you've noticed but if you want to put a " in the html you must put a \ before it so e.g value="bob" becomes value="bob" -->


that is only one page though, and it works so long you got a service that Accepts PHP otherwise you need to use Javascript but that IMO is not that secure

oh and since this is a php script save it as .php


You can see it working on my site www.cheekyboysoftware.tk

DaveOrdref
Preferred Member
 
Posts: 110
Joined: Jul 19th, '05, 21:29
Location: Sheepsville, Wales UK(17:AH)

Re: How to password protect a website section

Postby Tomo » Jul 31st, '05, 14:47

stephenmagic wrote:Does anyone know of a cheap or free way to put a password protected section onto a website?
The book PHP and MySQL for Dummies has a complete description for not much money.

Image
User avatar
Tomo
Veteran Member
 
Posts: 9866
Joined: May 4th, '05, 23:46
Location: Darkest Cheshire (forty-bloody-six going on six)

Postby Stephen Ward » Jul 31st, '05, 14:50

Thanks everyone :lol:

Stephen Ward
Veteran Member
 
Posts: 5848
Joined: Mar 23rd, '05, 16:21
Location: Lowestoft, UK (44:CP)

Postby DaveOrdref » Jul 31st, '05, 15:00

I will give the password to this site if anyone wants it.

I need people to test the trick on the site if that's ok

Thanks :)

DaveOrdref
Preferred Member
 
Posts: 110
Joined: Jul 19th, '05, 21:29
Location: Sheepsville, Wales UK(17:AH)


Return to Miscellaneous

Who is online

Users browsing this forum: No registered users and 65 guests