Guest User

Untitled

a guest
Mar 19th, 2018
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.23 KB | None | 0 0
  1. <?php
  2. function authenticate()
  3. {
  4.  
  5. $username = $_POST['username'];
  6. $pwd = $_POST['pwd'];
  7.  
  8. $con = mysqli_connect("localhost","root","","bankapp");
  9. $rs = $con->query("select count(username) from logindetails where username='$username' and password='$pwd'");
  10. $row = $rs->fetch_row();
  11. $n = $row[0];
  12.  
  13. $rs->free();
  14. $con->close();
  15.  
  16. if($n <> 0)
  17. {
  18. session_start();
  19. $_SESSION['uname'] = $username;
  20. header("Location: bal.php");
  21. }
  22. else
  23. {
  24. echo "<b>Authentication Failed</b>";
  25. }
  26.  
  27. }
  28. ?>
  29. <head>
  30. <title>DBS-Login</title>
  31. </head>
  32. <body>
  33. <h1>LOGIN</h1>
  34. <form method="POST">
  35. <table border="1">
  36. <tr>
  37. <td>Username </td>
  38. <td>
  39. <input type="text" name="username" />
  40. </td>
  41. </tr>
  42. <tr>
  43. <td>Password </td>
  44. <td>
  45. <input type="password" name="pwd" />
  46. </td>
  47. </tr>
  48. <tr align="center">
  49. <td colspan="2">
  50. <input type="submit" name="submit" value="Login" />
  51. </td>
  52. </tr>
  53. </table>
  54. </form>
  55. <?php
  56. if(isset($_POST['submit'])){
  57.  
  58. authenticate();
  59. }
  60. ?>
  61. </body>
  62. </html>
Add Comment
Please, Sign In to add comment