PHP Classes

How to Use a Set of PHP MVC Classes to Implement a Simple User Account System Using the Package Simple Auth OOP: Authenticate users using MVC classes

Recommend this page to a friend!
     
  Info   Example   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2025-03-14 (13 hours ago) RSS 2.0 feedNot yet rated by the usersTotal: Not yet counted Not yet ranked
Version License PHP version Categories
simple-auth-oop- 1.0The PHP License5PHP 5, User Management, Design Patterns
Description 

Author

This package can authenticate users using MVC classes.

It provides model, view and controller classes to implement a user authentication page.

The model class extends the database access class to access user records stored in a MySQL database table using the PHP PDO extension.

The controller class extends the model class to retrieve user records and stores the username and password in class variables.

The view class extends the model class to return the username of a user given his password.

The package provides scripts to implement pages to log in, logout and show a dashboard.

Picture of Adeleye Ayodeji
  Performance   Level  
Name: Adeleye Ayodeji <contact>
Classes: 30 packages by
Country: Nigeria Nigeria
Innovation award
Innovation award
Nominee: 18x

Example

<?php
 
 
include 'include/autoload.php';

  if (isset(
$_SESSION["username"])) {
     
header("location: dashboard.php");
  }

  if (isset(
$_POST["Submit"])) {
     
$Username = $_POST["Username"];
     
$Password = $_POST["Password"];

     
//Creating new object to fetch the base
     
$fetch = new UserView($Username, $Password);
      if (
$fetch->username == "user not found") {
         
$error = $fetch->username;
      }else{
       
$_SESSION["username"] = $fetch->username;
       
header("location: dashboard.php");
      }
  }
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <!-- This file has been downloaded from Bootsnipp.com. Enjoy! -->
    <title>Login Page - Bootsnipp.com</title>
        <meta name="viewport" content="width=device-width, initial-scale=1">
    <link href="http://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet">
    <style type="text/css">
         .wrapper {
    margin-top: 80px;
    margin-bottom: 20px;
}

.form-signin {
  max-width: 420px;
  padding: 30px 38px 66px;
  margin: 0 auto;
  background-color: #eee;
  border: 3px dotted rgba(0,0,0,0.1);
  }

.form-signin-heading {
  text-align:center;
  margin-bottom: 30px;
}

.form-control {
  position: relative;
  font-size: 16px;
  height: auto;
  padding: 10px;
}

input[type="text"] {
  margin-bottom: 0px;
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}

input[type="password"] {
  margin-bottom: 20px;
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}

.colorgraph {
  height: 7px;
  border-top: 0;
  background: #c4e17f;
  border-radius: 5px;
  background-image: -webkit-linear-gradient(left, #c4e17f, #c4e17f 12.5%, #f7fdca 12.5%, #f7fdca 25%, #fecf71 25%, #fecf71 37.5%, #f0776c 37.5%, #f0776c 50%, #db9dbe 50%, #db9dbe 62.5%, #c49cde 62.5%, #c49cde 75%, #669ae1 75%, #669ae1 87.5%, #62c2e4 87.5%, #62c2e4);
  background-image: -moz-linear-gradient(left, #c4e17f, #c4e17f 12.5%, #f7fdca 12.5%, #f7fdca 25%, #fecf71 25%, #fecf71 37.5%, #f0776c 37.5%, #f0776c 50%, #db9dbe 50%, #db9dbe 62.5%, #c49cde 62.5%, #c49cde 75%, #669ae1 75%, #669ae1 87.5%, #62c2e4 87.5%, #62c2e4);
  background-image: -o-linear-gradient(left, #c4e17f, #c4e17f 12.5%, #f7fdca 12.5%, #f7fdca 25%, #fecf71 25%, #fecf71 37.5%, #f0776c 37.5%, #f0776c 50%, #db9dbe 50%, #db9dbe 62.5%, #c49cde 62.5%, #c49cde 75%, #669ae1 75%, #669ae1 87.5%, #62c2e4 87.5%, #62c2e4);
  background-image: linear-gradient(to right, #c4e17f, #c4e17f 12.5%, #f7fdca 12.5%, #f7fdca 25%, #fecf71 25%, #fecf71 37.5%, #f0776c 37.5%, #f0776c 50%, #db9dbe 50%, #db9dbe 62.5%, #c49cde 62.5%, #c49cde 75%, #669ae1 75%, #669ae1 87.5%, #62c2e4 87.5%, #62c2e4);
}
   
    </style>
    <script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
    <script src="http://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
</head>
<body>
    <div class = "container">
    <div class="wrapper">
        <form action="" method="post" class="form-signin">
            <h3 class="form-signin-heading">Simple Auth OOP PHP</h3>
              <hr class="colorgraph"><br>
              <?php
         
if (isset($error)) {
           
?>
<div class="alert alert-danger text-center">
                <strong>Error!</strong> <?php echo $error; ?>
</div>
            <?php
         
}
       
?>
<input type="text" class="form-control" name="Username" placeholder="Username" required="" autofocus="" />
              <input type="password" class="form-control" name="Password" placeholder="Password" required=""/>
            
              <button class="btn btn-lg btn-primary btn-block" name="Submit" value="Login" type="Submit">Login</button>
        </form>
    </div>
</div>
  
<script type="text/javascript">

</script>
</body>
</html>


Details

simple-auth-oop-

Simple authentication in Object Oriented Programming by applying MVC Model


  Files folder image Files (12)  
File Role Description
Files folder imageinclude (2 files, 1 directory)
Accessible without login Plain text file dashboard.php Example Example script
Accessible without login Plain text file index.php Example Example script
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file logout.php Example Example script
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files (12)  /  include  
File Role Description
Files folder imageclass (5 files)
  Accessible without login Plain text file autoload.php Aux. Configuration script
  Accessible without login Plain text file simpleauth.sql Data Auxiliary data

  Files folder image Files (12)  /  include  /  class  
File Role Description
  Plain text file Dbh.php Class Class source
  Plain text file Logout.php Class Class source
  Plain text file UserController.php Class Class source
  Plain text file UserModel.php Class Class source
  Plain text file UserView.php Class Class source

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads  
 100%
Total:0
This week:0