Advertisement
sonnyrinaldo

login.php

May 5th, 2016
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.16 KB | None | 0 0
  1. <?php
  2.  
  3. require_once '../../include/sambung.php';
  4.  
  5. // username and password sent from form
  6. $myusername=$_POST['username'];
  7. $mypassword=($_POST['password']);
  8.  
  9. $siswa = mysql_num_rows(mysql_query("SELECT * FROM siswa WHERE idSiswa='$myusername' and password='$mypassword'"));
  10.  
  11. $ortu = mysql_num_rows(mysql_query("SELECT * FROM wali_murid WHERE idwali_murid='$myusername' and password='$mypassword'"));
  12.  
  13. $guru = mysql_num_rows(mysql_query("SELECT * FROM guru WHERE idGuru='$myusername' and password='$mypassword'"));
  14.  
  15. if($siswa==1){
  16. session_start();
  17.         $_SESSION['user']=$myusername;
  18.         $_SESSION['hak']="siswa";
  19.         $_SESSION['agent']=md5($_SERVER['HTTP_USER_AGENT']);
  20. header("location:index.php");
  21. }
  22. else if($ortu==1){
  23. session_start();
  24.         $_SESSION['user']=$myusername;
  25.         $_SESSION['hak']="ortu";
  26.         $_SESSION['agent']=md5($_SERVER['HTTP_USER_AGENT']);
  27. header("location:index.php");
  28. }else if($guru==1){
  29. session_start();
  30.         $_SESSION['user']=$myusername;
  31.         $_SESSION['hak']="guru";
  32.         $_SESSION['agent']=md5($_SERVER['HTTP_USER_AGENT']);
  33. header("location:index.php");
  34. }else{
  35. echo "<script>alert('Login gagal!'); document.location.href=\"index.php\"</script>";
  36. }
  37. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement