Guest User

Untitled

a guest
Jun 19th, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.61 KB | None | 0 0
  1. <?php
  2. session_start();
  3.  
  4. // Connect to DB.
  5. $db = mysqli_connect("localhost", "root", "", "soks");
  6.  
  7. if (isset($_POST['login_btn'])) {
  8.  
  9. $username=mysqli_real_escape_string($db,$_POST['username']);
  10. $password=mysqli_real_escape_string($db,$_POST['password']);
  11.  
  12. $password =md5($password);
  13. $sql = "SELECT * FROM users WHERE username='username' AND password='$password'";
  14. $result = mysqli_query($db,$sql);
  15.  
  16. if(mysqli_num_rows($result) == 1) {
  17. $_SESSION['message'] = "You are now logged in";
  18. $_SESSION['username'] = $username;
  19. header("location: home.php");
  20. }else{
  21. echo "Username/password combination incorrect";
  22. $_SESSION['message'] = "Username/password combination incorrect";
  23. }
  24. }
  25. ?>
  26. <!DOCTYPE html>
  27. <html>
  28. <head>
  29. <link rel="stylesheet" type="text/css" href="login.css">
  30. <meta charset="utf-8">
  31. <title>Sign in</title>
  32. </head>
  33. <body>
  34.  
  35. <div class="header">
  36. <hl>Sign in</hl>
  37. </div>
  38. <form class="form" method="post" action="login.php">
  39. <table>
  40. <tr>
  41. <td class="text">Username:</t[![введите сюда описание изображения][1]][1]d>
  42. <td><input type="text" name="username" class="textInput"></td>
  43. </tr>
  44. <tr>
  45. <td class="text">Password:</td>
  46. <td><input type="password" name="password" class="textInput"></td>
  47. </tr>
  48. <tr>
  49. <td></td>
  50. <td><input class="reg" type="submit" name="login_btn" value="Login"></td>
  51. </tr>
  52.  
  53.  
  54. </table>
  55. </form>
  56.  
  57. </body>
  58. </html>
Add Comment
Please, Sign In to add comment