e-Mail: Password: Forgotten password

webBRIEFCASE is a World class provider of a comprehensive range of affordable off-the-shelf and tailored business and IT services, which suit organisations of all sizes: from sole traders up to global and blue chip companies.

Logo



Web Briefcase Ltd Registered in
England & Wales
Reg no: 05393683
©2013-2018
Selected Records
Toolkit:
Tool:
Record Actions:
Table:
Selected records
Table wB_news_article
   

Implement a login system for your website

| Share |
Article text:
This article takes you through the creation of a very simple login system. These instructions assume that you have PHP available on your website, and that you are able to run such scripts. This version of the login system is very simplistic, and not very secure. A more complex / secure version will be made available on request.

session.php

Create a file called session.php. This will show a login form and check the login details which are supplied.

$email     = $_POST["email"];
$password = $_POST["password"];
$login = $_POST["login"];
$logout = $_POST["logout"];
$logged_in = $_POST["logged_in"];

if ($logout) {
$email = "";
$password = "";
$logged_in = "";
}

$show_form = "y";
if ($email == "") {
if ($login) {
?>Please supply your e-mail address
}
}
else {
if ($password == "") {
if ($login) {
?>Please supply your password
}
}
else {
if (
($email == "[EMAIL_ADDRESS"]" && $password == "[PASSWORD]")
||
($email == "[EMAIL_ADDRESS"]" && $password == "[PASSWORD]")
# Add more here
) {
$show_form = ""; # Don't show the form
         ?>Logged in as <?php echo $email; ?><br>
<input type="submit" name="logout" value="Logout">
<?php

# Determine some user privileges...
if (
$email == "[EMAIL_ADDRESS]"
|| $email == "[EMAIL_ADDRESS]
) {
$administrator = "y";
}
elseif (
$email = "[EMAIL_ADDRESS]"
|| $email = "[EMAIL_ADDRESS]"
)
{
$can_post = "y";
}
}
else {
?>Login failed

}
}
}
if ($show_form) {
?>
e-Mail: <input type="text" name="email" value="<?php echo $email; ?>">
Password:
<input type="password" name="password">
<input type="submit" name="login" value="Login">
<?php
}

Use the script

Add the following to each page / script you want to be protected with login...

require_once "session.php";

if ($logged_in) {

   if ($administrator) {

      ?>You are an administrator

   }

}

else {

   ?>Please login
<?php

}

 



Powered by the webBRIEFCASE Toolkit