Guest User

Untitled

a guest
Dec 5th, 2017
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 KB | None | 0 0
  1. <?php
  2.  
  3.  
  4. include('config.php');
  5.  
  6. // check if the fourm is submited
  7. if ($_SERVER['REQUEST_METHOD'] == 'POST') {
  8. // input from fourm
  9. $username = $_POST['username'];
  10. $password = $_POST['password'];
  11.  
  12. // pull records that match password
  13. $sql = file_get_contents('sql/attemptLogin.sql');
  14. $params = array(
  15. 'username' => $username,
  16. 'password' => $password
  17. );
  18. $statement = $database->prepare($sql);
  19. $statement->execute($params);
  20. $users = $statement->fetchAll(PDO::FETCH_ASSOC);
  21.  
  22. if(!empty($users)) {
  23. //first results
  24. $user = $users[0];
  25. //setting session varabals
  26. $_SESSION['userID'] = $user['userid'];
  27. $_SESSION['Username'] = $user['username'];
  28.  
  29. //home
  30. header('location: home.php');
  31. }
  32. }
  33. ?>
  34.  
  35. <!doctype html>
  36. <style>
  37. body{
  38. background-color:burlywood;
  39. }
  40.  
  41. #banner{
  42. background-image:url('Pics/foodBanner.jpg');
  43. width:100%;
  44. height: 200px;
  45. }
  46. #logincontent{
  47. position: absolute;
  48. top: 50%;
  49. left: 35%;
  50. background-color:orange;
  51. border: 5px solid black;
  52. }
  53.  
  54. </style>
  55.  
  56. <head>
  57. <meta charset="utf-8">
  58. <title>Login</title>
  59. </head>
  60.  
  61. <body>
  62. <div id ="banner"> </div>
  63. <div id = "logincontent">
  64. <h1>Login</h1>
  65. <form method="POST" action="">
  66. <input type = "text" name = "username" placeholder = "Username" />
  67. <input type = "password" name = "password" placeholder = "Password" />
  68. <input type="submit" value = "Log In" />
  69. </form>
  70. </div>
  71.  
  72. </body>
  73. </html>
Add Comment
Please, Sign In to add comment