Advertisement
Guest User

Untitled

a guest
Jun 9th, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. <? session_start(); ?>
  2. <html>
  3. <head>
  4. <title>Login</title></head>
  5. <body>
  6. <?php
  7. include('config.php');
  8. if ($_GET['action'] == "logout")
  9. {
  10. session_unset();
  11. session_destroy();
  12. if (!isset($_SESSION['login']))
  13. {
  14. echo 'Succesfully logged out';
  15. }
  16. }
  17. else
  18. {
  19. if (isset($_POST['Username']))
  20. {
  21. $Username = mysql_real_escape_string($_POST['Username']);
  22. $Password = mysql_real_escape_string($_POST['Username']);
  23. $db = mysql_select_db("login", $connect);
  24.  
  25. $query = mysql_query("SELECT * FROM users WHERE Username='" . $Username . "' and Password='" . $Password);
  26. $check = mysql_num_rows($query);
  27. if ($check > 0)
  28. {
  29. echo 'Succesfully logged in';
  30. $_SESSION['login'] = $Username;
  31. }
  32. else
  33. {
  34. echo 'Wrong Username/Password';
  35. }
  36. }
  37. if (isset($_SESSION['login']))
  38. {
  39. echo 'Welcome, ' .$_SESSION['login'];
  40. echo '<br /><a href="index.php?action=logout">Logout</a>';
  41. }
  42. else
  43. {
  44. echo '<form action="' .$_SERVER['PHP_SELF']. '" method="POST">';
  45. echo 'Username: <input type="text" name="Username" /><br />';
  46. echo 'Password: <input type="text" name="Password" /><br />';
  47. echo '<input type="submit" value="Log in" />';
  48. }
  49. }
  50. ?>
  51. </body>
  52. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement