You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <?php
  2. // SESSION STARTS IN includes/head.php
  3. require_once 'includes/dbase.inc';
  4. include 'includes/functions.inc';
  5. include 'includes/head.inc';
  6. ?>
  7. <fieldset class="main__content content">
  8. <legend>Log in</legend>
  9. <form action="./index.php" method="POST" class="content__form form">
  10. <label class="form__label" for="usr-name">Username</label>
  11. <input class="form__input" type="text" name="usr-name" id="usr-name" required autofocus value="<?php if (isset($_POST['usr-name'])) {
  12. echo $_POST['usr-name'];
  13. } ?>">
  14. <label class="form__label" for="password">Password </label>
  15. <input class="form__input" type="password" name="password" id="password" required value="<?php if (isset($_POST['password'])) {
  16. echo $_POST['password'];
  17. } ?>">
  18. <input class="form__input" type="submit" value="Log In" name="btn-login">
  19. </form>
  20. </fieldset>
  21. <div class="main__content message">
  22. <?php
  23. // Message die displayed of er een fout wachtwoord is, ...
  24. if (isset($_SESSION['mess'])) {
  25. echo $_SESSION['mess'];
  26. }
  27. if (isset($_POST['btn-login'])) {
  28. unset($_SESSION['mess']);
  29. checkLogin($_POST['usr-name'], $_POST['password']);
  30. if (isset($_SESSION['usr_id'])) {
  31. header('location: naval_battle.php');
  32. //stop het script
  33. exit();
  34. }
  35. // Checken of er errors zijn en indien ja, ze printen
  36. if (isset($_SESSION['err_mess'])) {
  37. // Om te vermijden dat $_SESSION['mess'] nog een boodschap heeft en plakt aan $_SESSION['err_mess']
  38. unset($_SESSION['mess']);
  39. echo $_SESSION['err_mess'];
  40. }
  41. }
  42. ?>
  43. </div>
  44. <?php
  45. if ($_SESSION['teacherMode']) {
  46. ?>
  47. <span class='alert'>*Teacher Mode*</span>
  48. <div class="main__content content">
  49. <!-- <center><span class="alert">*Tijdelijk*</span> -->
  50. <table>
  51. <tr>
  52. <th>Username</th>
  53. <th>Password</th>
  54. </tr>
  55. <?php
  56. $arr = $db->spoofDbTemporarily();
  57. while ($row = $arr->fetchArray(SQLITE3_ASSOC)) {
  58. echo '<tr><td>' . $row['usr_name'] . '</td><td>' . $row['password'] . "</td></tr>";
  59. }
  60. ?>
  61. </table>
  62. <!-- </center> -->
  63. </div>
  64. <?php } ?>
  65. <?php
  66. include 'includes/foot.inc';
  67. ?>