Advertisement
Guest User

Untitled

a guest
Sep 15th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.87 KB | None | 0 0
  1. <?php
  2. include("config.php");
  3. session_start();
  4.  
  5. if($_SERVER["REQUEST_METHOD"] == "POST") {
  6.     // username and password sent from form
  7.  
  8.     $myusername = mysqli_real_escape_string($db,$_POST['username']);
  9.     $mypassword = mysqli_real_escape_string($db,$_POST['password']);
  10.  
  11.     $sql = "SELECT id FROM admin WHERE username = '$myusername' and passcode = '$mypassword'";
  12.     $result = (mysqli_query($db,$sql)) (mysqli_error($db));
  13.     $row = mysqli_fetch_array($result,MYSQLI_ASSOC);
  14.     $active = $row['active'];
  15.  
  16.     $count = mysqli_num_rows($result);
  17.  
  18.     // If result matched $myusername and $mypassword, table row must be 1 row
  19.  
  20.     if($count == 1) {
  21.         session_register("myusername");
  22.         $_SESSION['login_user'] = $myusername;
  23.  
  24.         header("location: welcome.php");
  25.     }else {
  26.         $error = "Your Login Name or Password is invalid";
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement