Advertisement
Guest User

Untitled

a guest
Jun 28th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. <?php
  2. session_start();
  3. require 'config.php';
  4.  
  5. if (isset($_SESSION['id']) && !empty($_SESSION['id'])) {
  6. $id = $_SESSION['id'];
  7. $sql = "UPDATE usuarios SET on_off = '1' WHERE id = '$id'";
  8. $sql = $pdo->query($sql);
  9.  
  10. } else {
  11. header("location: login.php");
  12. }
  13.  
  14. ?>
  15.  
  16. <h1>Area Restrita</h1>
  17. <h2>Exibindo Usuarios On-Line</h2>
  18. <a href="sair.php"><button>Sair</button></a><br><br>
  19.  
  20. <?php
  21. $on = "SELECT * FROM usuarios";
  22. $on = $pdo->query($on);
  23. if ($on->rowCount() > 0)
  24. {
  25. foreach ($on->fetchAll() as $usuarios)
  26. {
  27. if ($usuarios['on_off'] == 1)
  28. {
  29. echo '<li>'.$usuarios['email'].' <span style="color:#1E90FF">On-Line</li>';
  30. }
  31. else
  32. {
  33. echo '<li>'.$usuarios['email'].' <span style="color:#FF0000">Off-Line</li>';
  34. }
  35.  
  36. }
  37. }
  38.  
  39. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement