Moderators: nickj, Lady of Mystery, Mandrake, bananafish, support
stephenmagic wrote:Does anyone know of a cheap or free way to put a password protected section onto a website?
<?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" -->
The book PHP and MySQL for Dummies has a complete description for not much money.stephenmagic wrote:Does anyone know of a cheap or free way to put a password protected section onto a website?
Users browsing this forum: No registered users and 65 guests