Advertisement
Guest User

Untitled

a guest
Feb 16th, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. // INDEX
  2.  
  3. <?php
  4. define('DB_SERVER', 'localhost');
  5. define('DB_USERNAME', 'root');
  6. define('DB_PASSWORD', '');
  7. define('DB_DATABASE', 'logindaten');
  8. $db = mysqli_connect(DB_SERVER,DB_USERNAME,DB_PASSWORD,DB_DATABASE) or die ("ERROR");
  9.  
  10. if($_SERVER["REQUEST_METHOD"] == "POST") {
  11. // username and password sent from form
  12.  
  13. $myusername = mysqli_real_escape_string($db,$_POST['username']);
  14. $mypassword = mysqli_real_escape_string($db,$_POST['password']);
  15.  
  16. $sql = "SELECT * FROM user WHERE Name = '$myusername' and Password = '$mypassword'";
  17. $result = mysqli_query($db,$sql);
  18. $row = mysqli_fetch_array($result,MYSQLI_ASSOC);
  19. $active = $row['active'];
  20.  
  21. $count = mysqli_num_rows($result);
  22.  
  23. if($count == 1) {
  24. $_SESSION['login_user'] = $myusername;
  25.  
  26. header("location: Welcome.php");
  27. }else {
  28. header("location: Login.html");
  29. }
  30. }
  31. ?>
  32. //Logout
  33. <?php
  34. session_start();
  35.  
  36. if(session_destroy()) {
  37. header("Location: Login.html");
  38. }
  39. ?>
  40.  
  41. //Welcome
  42. <html>
  43. <head>
  44. <title>Welcome </title>
  45. </head>
  46.  
  47. <body>
  48. <h1>Welcome </h1>
  49. <h2><a href = "Logout.php">Sign Out</a></h2>
  50. </body>
  51.  
  52. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement