Advertisement
Guest User

Untitled

a guest
Jul 3rd, 2018
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.04 KB | None | 0 0
  1. <?php
  2.     $db_server = "localhost:3306";
  3.     $db_username = "root";
  4.     $db_password = "root";
  5.     $db_name = "spatius";
  6.  
  7.     $conn = new mysqli($db_server,$db_username,$db_password,$db_name);
  8.  
  9.     if (!$conn)
  10.     {
  11.         die("Connection failed " . mysqli_connect_error());
  12.     }
  13.  
  14.     $enteredName = $_POST["email"];
  15.     $enteredPass = $_POST["password"];
  16.  
  17.     $query =  "SELECT password FROM admin WHERE username = '".$enteredName."'";
  18.     $result = mysqli_query($conn,$query);  
  19.    
  20.     if (mysqli_num_rows($result) > 0)
  21.     {
  22.         while($pass = mysqli_fetch_assoc($result))
  23.         {
  24.             if ($pass == $enteredPass)
  25.             {
  26.                 echo("Correct password");
  27.                 header("location:cp.php");
  28.             }
  29.             else
  30.             {
  31.                 echo("Password Incorrect, redirecting");
  32.                 header("location:index.php");
  33.             }
  34.         }
  35.     }
  36.     else
  37.     {
  38.         echo("Account not found, redirecting");
  39.         header("location:index.php");
  40.     }
  41.  
  42. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement