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.

42 lines
1.2 KiB

  1. <?php
  2. /**
  3. * Mempersiapkan session. session.use_trans_sid digunakan untuk menghindari
  4. * penyantuman Session ID pada setiap URL.
  5. *
  6. * Ref: https://stackoverflow.com/questions/1745984/php-session-use-trans-sid
  7. */
  8. ini_set('session.use_only_cookies', TRUE );
  9. ini_set('session.use_trans_sid', FALSE );
  10. session_start();
  11. require_once("conn/db.php");
  12. require_once('utils/helper.php');
  13. /**
  14. * Cek session serta token. Kemudian menyimpan nilai NIM dari session.
  15. */
  16. if (!isset($_SESSION['nim']) && !isset($_SESSION['token'])) {
  17. header('location:login.php');
  18. } else {
  19. $nim = $_SESSION['nim'];
  20. }
  21. if ($_POST['formSubmit'] == "Login") {
  22. $nims = $_POST['nim'];
  23. $pass = $_POST['pass'];
  24. $cekuser = odbc_exec($koneksi, "SELECT * FROM tb_mhs WHERE nim = '" . $nims . "'");
  25. $hasil = odbc_fetch_array($cekuser);
  26. if ($pass <> $hasil['pass']) {
  27. echo $pass . ' ' . $hasil['pass'];
  28. echo "Password salah!";
  29. header('location:login.php?s=2');
  30. } else if ($nims <> $hasil['nim']) {
  31. header('location:login.php?s=1');
  32. } else {
  33. $_SESSION['nim'] = $hasil['nim'];
  34. header('location:tampilanSION.php');
  35. }
  36. }