SHARE
TWEET

Login System Using Php And MySql Database

haikelfazzani Jul 21st, 2017 (edited) 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.     require_once("connection.php");
  3.  
  4.     if($_SERVER['REQUEST_METHOD'] == 'POST'){
  5.         $userName = $_POST["username"];
  6.         $passWord = $_POST["password"];
  7.        
  8.         $stmt = $connect->prepare("SELECT username,password FROM users_table
  9.         WHERE username = '$userName' AND password = '$passWord'
  10.         ");
  11.         $stmt->execute(array($userName,$passWord));
  12.        
  13.         $count = $stmt->rowCount();
  14.         if($count > 0){
  15.             session_start();
  16.             $_SESSION["username"] = $userName;
  17.             $_SESSION["password"] = $passWord;
  18.            
  19.             echo 'welcome' . '<br />' . $_SESSION["username"] . "<br />";
  20.             echo "<a href='logout.php'>Log Out</a>";
  21.         }else{
  22.             echo 'Error';
  23.         }
  24.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top