Guest User

Untitled

a guest
Feb 26th, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. <?php
  2.  
  3. /*
  4. ------------------------------------------------------
  5. login-validasi.php: menangkap variable yang dikirimkan
  6. pada file login.php
  7. ------------------------------------------------------
  8. */
  9.  
  10. require_once '../config/config.php';
  11.  
  12. if ( isset($_POST['username']) && isset($_POST['password']) ) {
  13.  
  14. $sql_check = "SELECT id,
  15. telegram_id
  16. FROM users
  17. WHERE
  18. username=?
  19. AND
  20. password=?
  21. LIMIT 1";
  22.  
  23. $check_log = $db->prepare($sql_check);
  24. $check_log->bind_param('ss', $username, $password);
  25.  
  26. $username = $_POST['username'];
  27. $password = md5( $_POST['password'] ); //enkripsi md5 just for example
  28.  
  29. $check_log->execute();
  30.  
  31. $check_log->store_result();
  32.  
  33. if ( $check_log->num_rows == 1 ) {
  34. $check_log->bind_result($id, $telegram_id, $auth_code);
  35.  
  36. // This is user session:
  37. while ( $check_log->fetch() ) {
  38. $_SESSION['user_login'] = $username;
  39. $_SESSION['telegram_id'] = $telegram_id;
  40.  
  41. }
  42.  
  43. $check_log->close();
  44.  
  45. // Jika berhasil login, maka akan diarahkan ke laman autentikasi
  46. header("location: autentikasi.php");
  47. exit();
  48.  
  49. // Jika gagal tetap di laman login dan menampilkan error
  50. } else {
  51. header('location: login.php?err='.base64_encode('Invalid Username or Password!'));
  52. exit();
  53. }
  54.  
  55.  
  56. } else {
  57. header('location:login.php');
  58. exit();
  59. }
Add Comment
Please, Sign In to add comment