Beatdigital

Websites made easy...

  • Increase font size
  • Default font size
  • Decrease font size
Home Articles PHP Authentication

PHP Authentication

E-mail Print PDF

Here is the script for simple php authentication, setting a session variable indicating that a user is logged in then redirecting them to the members.php page. If the login credentials are incorrect it will redirect the user to the homepage.

<?php
$username = $_POST['username'];
$password = $_POST['password'];

if( $username == 'admin' && $password == 'password' )
    {
        $_SESSION['loggedin'] = 'true';
    }

fclose($handle);

if(isset($_SESSION['loggedin']))
    {
        header('Location: member.php');
    }
else
    {
        header('Location: home.php');
    }
?>

 

Comments

Name *
Email (For verification & Replies)
URL
ChronoComments by Joomla Professional Solutions
Submit Comment