Advertisement
haikelfazzani

Login System Using Php And MySql Database

Jul 21st, 2017
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.64 KB | None | 0 0
  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.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement