Advertisement
Guest User

Untitled

a guest
Jan 30th, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. lib/connection.php
  2. <?php
  3. mysql_connect("localhost","root","") or die(mysql_error());
  4. mysql_select_db("test_db") or die(mysql_error());
  5. ?>
  6.  
  7. index.php
  8. <!DOCTYPE html>
  9. <html lang="en">
  10. <head>
  11. <meta charset="UTF-8">
  12. <title>Login</title>
  13. <link rel="stylesheet" href="css/style.css">
  14. </head>
  15. <?php
  16. include 'lib/connection.php';
  17. if (isset($_POST['login'])) {
  18. @$query = mysql_query("SELECT * FROM user_tb WHERE username='$_POST[username]' AND password='$_POST[password]'");
  19. @$cek=mysql_num_rows($query);
  20. if ($cek>0) {
  21. @$o=mysql_fetch_array($query);
  22. echo "Login success";
  23. }else{
  24. echo "Failed";
  25. }
  26. }
  27. ?>
  28. <body>
  29. <form method="post">
  30. <h4 align="center">Please don't let them blank</h4>
  31. <table align="center">
  32. <tr>
  33. <td>Username</td>
  34. <td>:</td>
  35. <td><input type="text" name="username" autofocus></td>
  36. </tr>
  37. <tr>
  38. <td>Password</td>
  39. <td>:</td>
  40. <td><input type="text" name="password"></td>
  41. </tr>
  42. <tr>
  43. <td></td>
  44. <td></td>
  45. <td><input type="submit" name="login" value="LOGIN"></td>
  46. <?php echo mysql_error() ?>
  47. </tr>
  48. </table>
  49. </form>
  50. </body>
  51. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement