Advertisement
Habaget

error

Jul 2nd, 2014
488
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 0.88 KB | None | 0 0
  1. <?php
  2. include("func.php");
  3.  $username=@$_POST['username'];
  4.  $userpass=@$_POST['userpass'];
  5. $link=koneksi_db();
  6.  $sql="select * from user where username='$username' and userpass=password('$userpass')";
  7. $res=mysql_query($sql,$link);
  8. if(mysql_num_rows($res)==1) // apabila username dan userpass benar
  9.  {
  10.  $data=mysql_fetch_array($res);
  11. session_start();
  12. //session_register("username","nama","level","sudahlogin");
  13. $_SESSION['username']=$data['username']; // isi variabel username
  14.  $_SESSION['nama']=$data['nama']; // isi vareiabel nama
  15. $_SESSION['level']=$data['level']; // isi variabel level
  16.  $_SESSION['sudahlogin']=true; // variabel status sudah login
  17. header("Location:index.php"); // pindah ke halaman index.php
  18. }
  19. else
  20.  {
  21.  
  22. ?>
  23.         <a href="index.php">
  24.         <script>
  25.         alert("username atau password salah!");
  26.         document.location="index.php";
  27.         </script>
  28.         </a>
  29.         <?php
  30.  }
  31.  
  32. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement