Advertisement
Guest User

login.php

a guest
Sep 11th, 2016
307
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.56 KB | None | 0 0
  1. <?php
  2.  
  3. include '../../config/koneksi.php';
  4.  
  5. // username and password sent from form
  6. $myusername=$_POST['username'];
  7. $mypassword=md5($_POST['password']);
  8.  
  9. $siswa=mysql_num_rows(mysql_query("SELECT * FROM siswa WHERE idSiswa='$myusername' and password='$mypassword'"));
  10.  
  11.  
  12. if($siswa==1){
  13. session_start();
  14.         $_SESSION['user']=$myusername;
  15.         $_SESSION['hak']="siswa";
  16.         $_SESSION['agent']=md5($_SERVER['HTTP_USER_AGENT']);
  17. header("location:../index.php");
  18.  
  19. }else{
  20. echo "<script>alert('Login gagal!'); document.location.href=\"index.php\"</script>";
  21. }
  22. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement