Advertisement
Guest User

huhha

a guest
Feb 16th, 2017
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. <?php
  2. class Library{
  3. public function __construct(){
  4. $this->db = new PDO('mysql:host=localhost;dbname=bismillah','root','');
  5. }
  6.  
  7.  
  8. public function loginuser($username, $password) {
  9. if($this->cekanggota($username)){
  10. $this->loginanggota($username,$password);
  11. }else{
  12. $this->loginpetugas($username,$password);
  13.  
  14. }
  15.  
  16. }
  17.  
  18.  
  19. public function cekanggota($idAnggota) {
  20. $result = $this->db->prepare("SELECT * FROM anggota WHERE id_anggota= '$idAnggota'");
  21.  
  22. $result->bindParam(1, $idAnggota);
  23. $result->execute();
  24. if($result->fetchColumn()>0){
  25. return true;
  26. }
  27. return false;
  28. }
  29.  
  30. public function loginpetugas($username, $password) {
  31.  
  32. $result = $this->db->prepare("SELECT * FROM user WHERE username='$username' AND password= '$password'");
  33. $result->bindParam(1, $username);
  34. $result->bindParam(2, $password);
  35. $result->execute();
  36. $rows = $result->fetch();
  37. return $rows;
  38. }
  39.  
  40.  
  41. public function loginanggota($id_anggota, $nama) {
  42. $result = $this->db->prepare("SELECT * FROM anggota WHERE nama='$nama' AND id_anggota= '$id_anggota'");
  43. $result->bindParam(1, $username);
  44. $result->bindParam(2, $password);
  45. $result->execute();
  46. $rows = $result->fetch();
  47. return $rows;
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement