Advertisement
Guest User

Untitled

a guest
Jun 27th, 2019
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>Login</title>
  6. <link rel="stylesheet" href="css/style.css"/>
  7. </head>
  8. <body>
  9. <?php
  10. require('db.php');
  11. session_start();
  12.  
  13. if (isset($_POST['username'])){
  14. $username = $_REQUEST['username'];
  15. $password = $_REQUEST['password'];
  16.  
  17. $sql = "SELECT * FROM `users` WHERE username='$username' and
  18. password='".md5($password)."'";
  19. $result = $conn->query($sql) or die(mysqli_error());
  20. if($result->num_rows > 0){
  21. $_SESSION['username'] = $username;
  22. header("Location: index.php"); //Redirect user to index.php
  23. }else{
  24. echo "<div class='form'><h3>Username/password is
  25. incorrect.</h3><br>Click here to <a
  26. href='login.php'>Login</a></div>";
  27. }
  28. }else{
  29. ?>
  30. <div class="form">
  31. <h1>Log In</h1>
  32. <form action="" method="post" name="login">
  33. <input type="text" name="username" placeholder="Username"
  34. required />
  35. <input type="password" name="password" placeholder="Password"
  36. required />
  37. <input name="submitted" type="submit" value="Login" />
  38. </form>
  39. <p>Not registered yet? <a href='registration.php'>Register
  40. Here</a></p>
  41.  
  42. </div>
  43. <?php } ?>
  44.  
  45. </body>
  46. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement