Login PHP And MySQLI

Login PHP and with MySQLI, Login system is the key feature of any website, because for user authentication we use login system now you can below login system is the key feature of website.

PHP & MySQLI Simple Login System

In this today article, we will create a simple login PHP system with MySQLI database, the login system is very important for any education and business dynamic website same like Gmail, Facebook and Twitter are best examples of dynamic websites. so in this today article, we will learn how to create a simple login system using PHP and MySQLI
login php

Steps to a Login System:

  1. Create database with a name of login, just goto phpmyadmin and click on databases and after click on SQL tab and copy the below code and past in SQL filed area on now click on GO 
  2. create DATABASE login

  3. database file
  4. CREATE TABLE `user` (
     `id` int(11) NOT NULL AUTO_INCREMENT,
     `email` varchar(255) NOT NULL,
     `password` varchar(100) NOT NULL,
     PRIMARY KEY (`id`) ENGINE=InnoDB DEFAULT CHARSET=latin
  5. connection.php
  6. <?php session_start();
    $db = mysqli_connect("localhost","root", "","login");
    return $db; ?>
    
  7. Index.php
  8. <?php
    include "connection.php";
    if(isset($_POST['login'])){
        $error = "";
        $email     = trim(mysqli_real_escape_string($db, $_POST['email']));
        $password  = trim(mysqli_real_escape_string($db, $_POST['password']));
        $Query     = mysqli_query($db, "SELECT * FROM user WHERE email = '$email' && password = '$password'");
        if(mysqli_num_rows($Query) == 1){
            $_SESSION['username'] = $email;
            header("location:home.php");
        }else{
            $error = "Your Password OR Email is not matched!";
        }
        
    }
    
    ?>
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Login System in PHP</title>
       <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
    </head>
    <body>
       <div class="container" style="margin-top:40px;">
           <div class="row">
               <div class="col-md-4 col-md-offset-4">
                 <?php if(isset($error)):   ?>
                 <div class="alert alert-danger"><?php echo $error; ?></div>
                 <?php endif;?>
                  <div class="panel panel-primary">
                      <div class="panel-heading">
                          <h2>Login System</h2>
                      </div><!-- close panel-heading -->
                      <div class="panel-body">
                          <form action="" method="POST">
                              <div class="form-group">
                                  <input type="email" name="email" class="form-control" placeholder="Enter Email...." required>
                              </div><!-- close form-group -->
                              <div class="form-group">
                                  <input type="password" name="password" class="form-control" placeholder="Enter Password...." required>
                              </div><!-- close form-group -->
                              <div class="form-group">
                                  <input type="submit" name="login" class="btn btn-default" value="Login">
                              </div><!-- close form-group -->
                          </form><!-- close form-->
                      </div><!-- close panel-body -->
                  </div><!-- close panel --> 
               </div><!-- close col -->
           </div><!-- close row -->
       </div> <!-- close container -->
    </body>
    </html>
    
  9. home.php
  10. <?php
    include "connection.php";
    if(!isset($_SESSION['username'])):
    header("location:index.php");
    endif;
    
    ?>
    <h1>welcome to dashboard</h1>
    <a href="logout.php">logout</a>
  11. logout.php
  12. 
    session_start();
    session_destroy();
    header("location:index.php"); 

COMMENTS

Name

ajax,2,HTML & CSS,19,JavaScript,1,PHP,11,
ltr
item
webtipstricks: Login PHP And MySQLI
Login PHP And MySQLI
Login PHP and with MySQLI, Login system is the key feature of any website, because for user authentication we use login system now you can below login system is the key feature of website.
https://1.bp.blogspot.com/-IR9lMZrgDgc/WtOHWpTzO5I/AAAAAAAABhU/3yCn6xKCq3QeNCL_YWsMfVaqzPh-YiHmACLcBGAs/s640/LOGIN%2BPHP%2BAND%2BMYSQLI.png
https://1.bp.blogspot.com/-IR9lMZrgDgc/WtOHWpTzO5I/AAAAAAAABhU/3yCn6xKCq3QeNCL_YWsMfVaqzPh-YiHmACLcBGAs/s72-c/LOGIN%2BPHP%2BAND%2BMYSQLI.png
webtipstricks
https://www.webtipstricks.com/2017/10/login-php-and-mysqli.html
https://www.webtipstricks.com/
https://www.webtipstricks.com/
https://www.webtipstricks.com/2017/10/login-php-and-mysqli.html
true
4027471107773963481
UTF-8
Loaded All Posts Not found any posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS CONTENT IS PREMIUM Please share to unlock Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy