Advertisement
myarkqub

login - home.php

Aug 11th, 2019
293
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.48 KB | None | 0 0
  1.  
  2. <a href="home.php?logout"><button>Logout</button></a>
  3.  
  4.  
  5. <?php
  6. $conn = mysqli_connect("127.0.0.1", "root", "123123", "login");
  7.  
  8. session_start();
  9.  
  10.  
  11. $user_info = mysqli_fetch_assoc(mysqli_query($conn, "SELECT username FROM users WHERE id = '$_SESSION[id]'"));
  12.  
  13. echo "WELCOME $user_info[username]";
  14.  
  15. if(isset($_GET["logout"])){
  16.     session_unset();
  17.     session_destroy();
  18.     header("Location: index.php");
  19. }
  20.  
  21.  
  22. if(!isset($_SESSION["id"])){
  23.     header("Location: index.php");
  24. }
  25.  
  26. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement