Guest User

Untitled

a guest
Apr 13th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. <?php
  2. session_start();
  3. $conn = new mysqli("localhost", "root", "", "park");
  4. if(isset($_POST['login_btn']))
  5. {
  6. $username= $_POST['username'];
  7. $password= $_POST['password'];
  8.  
  9. $password=md5($password);
  10. $sql= "SELECT * FROM users WHERE username='$username' AND Password='$password'";
  11. $result = mysqli_query($conn,$sql) or die(mysqli_error());
  12. $rows = mysqli_num_rows($result);
  13. if($rows==1){
  14. $_SESSION['username'] = $username;
  15. header("Location: success.php");
  16. }else{
  17. echo "<div class='form'>
  18. <h3>Username/password is incorrect.</h3>
  19. <br/>Click here to <a href='login.php'>Login</a></div>";
  20. }
  21.  
  22. }
  23. ?>
  24. <html>
  25. <body>
  26. <div id="bodyContent">
  27. <h1> Login </h1>
  28. </div>
  29. <form method="post">
  30. <table>
  31. <tr>
  32. <td>Username: </td>
  33. <td>
  34. <input type="text" name="username" class="textInput">
  35. </td>
  36. </tr>
  37.  
  38. <tr>
  39. <td>Password: </td>
  40. <td>
  41. <input type="password" name="password" class="textInput">
  42. </td>
  43. </tr>
  44.  
  45. <tr>
  46. <td> </td>
  47. <td>
  48. <input type="submit" name="login_btn" value="Login">
  49. </td>
  50. </tr>
  51.  
  52. </table>
  53. </form>
  54. </body>
  55. </html>
Add Comment
Please, Sign In to add comment