Giter Club home page Giter Club logo

php-membership's Introduction

What is php-membership?

Releases | Functionallity | Installation | Requirements | Security | License

Php-membership is an open-source project that provides a simple, secure, and scalable membership system for your website. This system is 100% secure and it validates all data that is sent from the client.
It is easy to deploy even with no previous knowledge about membership systems.

Functionallity

Php-membership 1.0 is able to:

  • Create users.
    You are able to register users with an username and password from the client.
  • Log-in with users.
    You are able to log-in with an existing user.
  • Log-out with users.
    You are able to log-out from an user within a members-only area.
  • Use members-only areas.
    You are only able to visit members-only webpages if you are logged in as an existing user.
  • Check if an user is logged in.
    Php-membership checks if you are logged in with an existing user before letting you visit a members-only webpage.

Installation

The only thing you will need to configure are the credentials in connect.php.
It is now configured to connect with localhost using the default credentials.

Change these default credentials to fit your own:

$host = 'localhost'; //database host
$user = 'root'; //database username
$pass = NULL; //database password
$dbname = 'membership'; //database name

How to install php-membership on your server:

  1. Import /php-membership/code/sql/users.sql to your database.
  2. Upload php-membership to your server.
  3. Open YOUR HOST HERE/php-membership/code/php/index.php in your browser.

Requirements

The minimal requirements for using the latest version of php-membership are:

  • PHP 5.3.7.

Security

Client-side validation

Validation of client-submitted data is only added because of better user experience.
The user may not have a web browser that support the use of required and pattern for HTML forms.
You should never trust data from a client because an user can use other clients than a web browser to submit data.
The only client-side validation are the input fields in register.php and login.php.

The user cannot submit the data unless they follow this set of rules:

  • pattern="[a-zA-Z0-9-]+"
    Username must only contain letters and numbers.
  • required
    Username and Password cannot be empty.

Server-side validation

You need to make sure that all data sent from the client is safe before reaching the database.
Php-membership uses different methods of protecting your database from malicious data.

  • SET NAMES utf8mb4
    Before making a query, php-membership tells your DBMS to expect the data to be sent with the utf8mb4 character set.
  • stripslashes()
    Un-quotes a quoted string before using it.
  • mysqli_real_escape_string()
    Removes any special characters in a string before using it.
  • strlen(string) === 0
    Php-membership checks if the fields somehow ended up being sent empty after the client-side validation.
  • ctype_alnum()
    Php-membership checks if the data only contains letters and numbers.
  • mysqli_prepare()
    Php-membership is using prepared statements which sends a prepared query template to you DBMS before executing the query.

Secure password storage

Php-membership is using the password_hash function to store passwords in the database.

Passwords are automatically hashed with password_hash($post_password, PASSWORD_DEFAULT) when an user is successfully submitted.
An user will look something like this in the database:
| 1 | JamesBond16 | $2y$10$ZClCKTG4SGFna9fXUTYkvOrM6AcKZtevdL8n2kzOBZtb4xXV6zhy6 |

This prevents an attacker from retrieving passwords even if they are able to view the database table.
Php-membership uses password_verify() when comparing a password sent from login.php with the password hash stored in the database.

Resources

php-membership's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.