Advertisement
Guest User

config.php

a guest
Dec 10th, 2016
125
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.  
  3. $host="localhost";
  4. $db_name="local1";
  5. $db_user="admin";
  6. $db_password="pass";
  7.  
  8. $con = mysqli_connect($host, $db_user, $db_password);
  9. $username = $_POST["username"];
  10. $password = $_POST["password"];
  11. mysqli_select_db($con, $db_name);
  12. $query = "SELECT * FROM users WHERE username='$username'";
  13. $result = mysqli_query($con, $query);
  14.  
  15.  
  16.   echo "<pre>";
  17.  
  18.   if (mysqli_errno($con) !== 0) {
  19.     echo "SQL error: ", htmlspecialchars(mysqli_error($con)), "\n";
  20.    
  21.   }
  22.   echo "</pre>";
  23.  
  24. if (!$result) {
  25.    
  26.     exit();
  27. }
  28. $logged_in = false;
  29.     $row=mysqli_fetch_array($result);
  30.   if ($row["password"] === $password) {
  31.     $logged_in = true;
  32.     echo "<h1>Logged in!</h1>";
  33.     echo "<pre>User level: ", $row["user_level"],  "</pre>";
  34.     if ($row["user_level"] >= 50) {
  35.       echo "<p>Congarts :D ! you have found a high level user \n tell the admin to always use intval(GET['id'])</p>";
  36.     } else {
  37.       echo "<p>you didn't find a user that has a high level.</p>";
  38.     }
  39.   }
  40.   else
  41.     echo "Wrong Username or Password :( !";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement