Advertisement
myarkqub

admin and user

Aug 29th, 2019
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.45 KB | None | 0 0
  1. <?php
  2. $conn = mysqli_connect("localhost", "root", "", "database");//ubah yang ni
  3. session_start();
  4. if(isset($_SESSION["username"])){
  5.     $user_info = mysqli_fetch_assoc($conn, "SELECT * FROM users WHERE username = '$_SESSION[username]'");
  6.     if($user_info["type"] == "admin"){
  7.        
  8.         echo "YOU ARE ADMIN.";
  9.     }
  10.     else{
  11.        
  12.         echo "YOU ARE USER. (Booo)";
  13.     }
  14. }
  15. else{
  16.     echo "require login to view this pages. <a href='login.php'>go to login page.</a>";
  17. }
  18.  
  19. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement