Guest User

Untitled

a guest
Oct 9th, 2017
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. <?php
  2. function mute(){
  3. echo "<!--";
  4. }
  5.  
  6. function unmute() {
  7. echo "-->";
  8. }
  9. ?>
  10.  
  11. <?php
  12. $file = fopen('pass.csv', 'r');
  13. while (!feof($file)) {
  14. $data[] = fgetcsv($file);
  15.  
  16. }
  17.  
  18. //echo (array_search('qwer', array($data)));
  19. $success = array_filter($data, 'filter_name_pass', ARRAY_FILTER_USE_BOTH);
  20.  
  21.  
  22. //print_r($data);
  23. fclose($file);
  24. ?>
  25.  
  26.  
  27. <?php
  28. function filter_name_pass($val)
  29. {
  30. return $val[0] == $_POST['username'] &&
  31. $val[1] == $_POST['password'];
  32. }
  33. ?>
  34.  
  35. <?php // Not Logged in
  36. if ($success) mute();
  37. ?>
  38. <form method="POST", action="index.php">
  39. <label for="username">Username:</label>
  40. <input type="text" name="username">
  41.  
  42. <br/>
  43.  
  44. <label for="password">Password:</label>
  45. <input type="text" name="password">
  46. <br/>
  47. <input type="submit" name="submit">
  48.  
  49. </form>
  50. <?php
  51. if ($success) unmute();
  52. ?>
  53.  
  54.  
  55. <?php // Logged in
  56. if (!$success) mute();
  57. ?>
  58. <h1>Login sukses!</h1>
  59. <h2>Halo, <? echo $_POST['username']; ?></h2>
  60. <?php
  61. if (!$success) unmute();
  62. ?>
Add Comment
Please, Sign In to add comment