Skip to main content
Known Participant
December 7, 2006
Question

Password protection without a username

  • December 7, 2006
  • 2 replies
  • 322 views
Using DW8 and PHP.

Is there a way I can use DW authentication but it only check for a password instead of both a username and password? I know its not secure and I won't be using sessions/cookies. Thanks!
This topic has been closed for replies.

2 replies

Inspiring
December 8, 2006
You really need to use session variables or cookies, otherwise you can't
tell if the user has logged in correctly or not on subsequent pages, ie they
can go to any protected page if they know the address and view it.

If you just want a password, you can use the following simple code:

Add the line below to line one of each page using session variables:

<?php session_start(); ?>

On your login page, named login.php add a form with the action set to
login.php (so that it submits to itself) with a text field called password.

Then add to the top of the login.php page, under session_start():

<?php
if(strlen($_POST['password']) > 0){
if($_POST['password'] == "mypassword"){
$_SESSION['logged_in'] == "1";
header("Location: http://www.mywebsite.com/success.php");
}
}
?>

That will redirect to success.php if the user types in the correct password.

On any page you want to secure use:

<?php
session_start();
if($_SESSION['logged_in'] <> 1){
header("Location: http://www.mysite.com/login.php");
}

That will create a very simple login system, that will secure your pages.

--
Gareth
http://www.phploginsuite.co.uk/
PHP Login Suite V2 - 34 Server Behaviors to build a complete Login system.


EiolonAuthor
Known Participant
December 7, 2006
Nevermind, I was able to find a way to accomplish this.