Advertisement
Guest User

Untitled

a guest
Feb 6th, 2019
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. <?php
  2. $servername = "localhost";
  3. $username = "root";
  4. $password = "";
  5. $database = "";
  6.  
  7. try {
  8. $conn = new PDO("mysql:host=$servername;dbname=$database", $username, $password);
  9. // set the PDO error mode to exception
  10. $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  11. }
  12. catch(PDOException $e)
  13. {
  14. echo "Connection failed: " . $e->getMessage();
  15. }
  16.  
  17. $rank = $conn->prepare("SELECT rank FROM users WHERE username = :username");
  18. $rank->execute(array(
  19. ':username' => $_SESSION['user']['username']
  20. ));
  21.  
  22. while ($check = $rank->fetch(PDO::FETCH_ASSOC)){
  23. if ($check['rank'] == 1) {
  24. echo 'Je bent admin.';
  25. }
  26. }
  27. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement