Guest User

Untitled

a guest
May 6th, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.61 KB | None | 0 0
  1. <?php include 'layout.php'; ?>
  2.  
  3. <head>
  4. <title>Login</title>
  5. </head>
  6.  
  7.  
  8. <link rel="stylesheet" href="/custom_CSS/loginCSS.css" type="text/css" />
  9.  
  10. <body>
  11. <h1>
  12. Login
  13. </h1>
  14.  
  15. <div class="loginForm">
  16. <form method="post">
  17. <p class="login_prompt">Login using your username and password.</p>
  18. <input type="text" name="username" placeholder="Username"><br /><br />
  19.  
  20. <input type="password" name="password" placeholder="Password"><br />
  21.  
  22. <label id="remembermeLabel">Remember me</label>
  23. <input type="checkbox" name="remembermecheck" value="remember"><br />
  24.  
  25. <input type="submit" name="loginButton" value="Login" />
  26. </form>
  27.  
  28.  
  29. <?php
  30.  
  31. session_start();
  32.  
  33. require 'connectDB.php';
  34.  
  35. if(!empty($_POST['username']) && !empty($_POST['password']))
  36. {
  37. $hashpassword = hash('sha512', $_POST['password']);
  38.  
  39. $sql = 'SELECT userID, name, username FROM user WHERE username = "'.$_POST['username'].'" AND password = "'.$hashpassword.'";';
  40.  
  41. $result = $conn->query($sql);
  42.  
  43. if(mysqli_num_rows($result) == 1)
  44. {
  45. $row = $result->fetch_assoc();
  46. $_SESSION['user_id'] = $row['userID'];
  47. header("Location: index.php");
  48. }
  49. else
  50. {
  51. $message = "Error";
  52. echo "$message";
  53. }
  54. }
  55. ?>
  56. </div>
  57.  
  58.  
  59.  
  60. </body>
Add Comment
Please, Sign In to add comment