Advertisement
Guest User

Untitled

a guest
Oct 2nd, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.02 KB | None | 0 0
  1. <?php
  2.     header('Content-type: application/json');
  3.     header('Accept: application/json');
  4.     $servername = "localhost";
  5.     $username = "root";
  6.     $password = "8357NOse";
  7.     $dbname = "loginsystem";
  8.  
  9.     $conn = new mysqli($servername,$username,$password,$dbname);
  10.  
  11.     if($conn -> connect_error){
  12.         header("HTTP/1.1 500 SHET IS BROKEN YOOOWWW (Bad connection, portal down)");
  13.         die("Mother fucker (Ther server is down, we couldnt stablish the database connection)");
  14.     }else{
  15.         $uName = $_POST["uName"];
  16.         $uPassword = $_POST["uPassword"];
  17.         $sql = "SELECT * FROM Users WHERE '$uName' = username AND passwrd = '$uPassword'";
  18.  
  19.         $result = $conn -> query($sql);
  20.  
  21.         if($result->num_rows>0){
  22.             while($row = $result->fetch_assoc()){
  23.                 $response = array("Firstname"=>$row["fName"],"Lastname"=>$row["lName"],"username"=>$row["username"],"Firstname"=>$row["passwrd"]);
  24.             }
  25.             echo json_encode($response);
  26.         }else{
  27.             header("HTTP/1.1 406 User not found.");
  28.             die("Type your shit right son (Wrong credentials provided)");
  29.         }
  30.     }
  31. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement