Giter VIP home page Giter VIP logo

kshitizrohilla / login-signup-using-php-mysql Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 2.0 292 KB

A simple LogIn and SignUp system made using PHP on the server side and MySQL for storing client's database consisting of their username, email and passoword using password_hash() function using a strong one-way hashing algorithm.

PHP 69.54% Hack 20.70% CSS 9.77%
login mysql mysql-server php phpmyadmin signup login-form-design login-forms login-page login-system

login-signup-using-php-mysql's Introduction

LogIn And SignUp using PHP and MySQL

A simple LogIn and SignUp system made using PHP on the server side and MySQL for storing client's database consisting of their username, email and passoword using password_hash() function using a strong one-way hashing algorithm.

Setup

  • Start the Apache and MySQL server from the XAMPP control panel.
  • Extract the downloaded git project folder in the htdocs folder(present in the XAMPP folder). Generally during installation the XAMPP is installed in the C: Drive of your computer.
  • A common file structure might looks like this:
C:
|----XAMPP
     |----htdocs
          |----login-signup-php-mysql-main
               |----styles
                    |----index.css
               |----database.php
               |----login.php
               |----logout.php
               |----signup.php
               |----process_signup.php
               |----signup_success.php
               |----index.php
  • To create client's database go to: http://localhost/phpmyadmin

  • Start by creating a new database from the left sidebar named as 'login_db' with the default server connection collation settings.

  • After creating the database create a table named as 'user' with 4 columns for id, username, email and password_hash.

  • The first column is 'id' which is an integer. Check the Auto Increment checkbox which will also make this field the primary key.

  • The next column will be for the 'username' and we'll make this a 128 character VARCHAR.

  • The next column is for the 'email' which we'll make a 255 character VARCHAR. We will also specify a unique index on this column which will ensure no two field can have same values.

  • The next column will be of 'password_hash' which we'll make a 255 character VARCHAR.

NOTE: It is recommended to store the password_hash in a 255 character VARCHAR as the one-way hashing algorithm is designed to change over time as new and stronger algorithms are added to PHP. For that reason, the length of the result from using this identifier can change over time. Therefore, it is recommended to store the result in a database column that can expand beyond 60 characters.

Features

  • The password is stored as a password hash instead of clear text. This is because if the attacker gets hold of the database they then have a list of login emails and passowords which they can use to login into the site. Also some people use the same password for different sites which will allow attacker to gain access to other sites. The password_hash() function uses various different algorithms but its simplest just to use the default. For more information refer to PHP password_hash() function docs: https://www.php.net/manual/en/function.password-hash.php

  • To avoid an SQL injection attack the value received from the login form is being escaped by using the real_escape_string method of the mysqli object(refer to the login.php file for more clarity). For more information visit: https://www.php.net/manual/en/mysqli.real-escape-string.php

  • As we are starting the secession at the top of the index page, when the login page is being loaded the secession will already be started. This will make the code vulnerable to a session fixation attack. To avoid this once we have logged in successfully we regenerate the id by calling the session_regenerate_id() function. For more information visit: https://www.php.net/manual/en/function.session-regenerate-id.php

Screenshots

login-signup-php-mysql-screenshot-mobile login-signup-php-mysql-screenshot-mobile login-signup-php-mysql-screenshot-mobile login-signup-php-mysql-screenshot-mobile

login-signup-using-php-mysql's People

Contributors

kshitizrohilla avatar

Stargazers

 avatar  avatar

Watchers

 avatar

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.