Advertisement
Guest User

Untitled

a guest
Nov 13th, 2016
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.56 KB | None | 0 0
  1. <?php
  2. session_start();
  3.  
  4. if(!isset($_SESSION['user']))
  5. {
  6. header("location: login.php");
  7. }
  8. ?>
  9.  
  10. <?php
  11. session_start();
  12.  
  13. if(isset($_POST['uname']))
  14. {
  15. include_once("dataBase.php");
  16.  
  17. $username = strip_tags($_POST['uname']);
  18. $password = strip_tags($_POST['pass']);
  19.  
  20. $username = stripslashes($username);
  21. $password = stripslashes($password);
  22.  
  23. $username = mysql_real_escape_string($username);
  24. $password = mysql_real_escape_string($password);
  25.  
  26. $sql = "SELECT * FROM users WHERE Username='$username'";
  27. $qry = mysql_query($sql);
  28. $row = mysql_fetch_row($qry);
  29. $user = $row[0];
  30. $pass = $row[1];
  31. if($pass == $password)
  32. {
  33. $_SESSION['user'] = $username;
  34. header("location: Home.php");
  35. }
  36. else
  37. {
  38. echo "Incorrect Details!";
  39. header("location: logout.php");
  40. }
  41. }
  42. ?>
  43. <html>
  44. <head>
  45. <title>Login</title>
  46. <meta charset = "utf-8"/>
  47. <link rel = "stylesheet" type = "text/css" href="style.css"/>
  48. </head>
  49.  
  50. <body>
  51. <div class = "header"><h1>Library</h1>
  52. </div>
  53.  
  54. <div id = "loginForm">
  55. <form method = "POST">
  56. Username: <br>
  57. <input type = "text" name = "uname"/><br>
  58. Password: <br>
  59. <input type = "password" name = "pass"/><br>
  60. <input type = "submit" name = "login" value = "Login"/><a href = "registration.php"><input type = "button" value = "Register"/></a>
  61. </form>
  62. </div>
  63.  
  64. <div class = "footer">
  65. </div>
  66. </body>
  67. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement