Advertisement
fajriansyah

login1

Oct 26th, 2016
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.31 KB | None | 0 0
  1. <?php
  2. @session_start();
  3. include "inc/koneksi.php";
  4.  
  5. if(@$_SESSION['admin']= $data['kode user'] || @$_SESSION['operator']= $data['kode user']) {
  6.     header("location: index.php");
  7. } else {
  8. ?>
  9. <!DOCTYPE html>
  10. <html>
  11. <head>
  12.     <title>HALAMAN LOG IN</title>
  13. <style type="text/css">
  14.     body{
  15.         font-family: arial;
  16.         font-size: 14px;
  17.         background-color: #222;
  18.  
  19.     }
  20.  
  21. #utama{
  22.     width: 300px;
  23.     margin: 0 auto;
  24.     margin-top: 12%;
  25.    
  26. }
  27.  
  28. #judul{
  29.     padding: 15px;
  30.     text-align: center;
  31.     color: #fff;
  32.     font-size: 20px;
  33.     background-color: #339966;
  34.     border-top-right-radius: 10px;
  35.     border-top-left-radius: 10px;
  36.     border-bottom: 3px solid #336666;
  37. }
  38.  
  39. #input{
  40.     background-color: #ccc;
  41.     padding: 20px;
  42.     border-bottom-left-radius: 10px;
  43.     border-bottom-right-radius: 10px;
  44. }
  45. input {
  46.     padding: 10px;
  47.     border : 0;
  48.  
  49. }
  50. .lg{
  51.     width: 220px
  52. }
  53. .btn{
  54.     background-color: #339966;
  55.     border-radius: 10px;
  56.     color: #fff;
  57. }
  58. .btn:hover{
  59.     background-color: #336666;
  60.     border-radius: 10px;
  61.     cursor: pointer;
  62. }
  63. </style>
  64. </head>
  65. <body>
  66. <div id="utama">
  67.     <div id="judul">
  68.     HALAMAN LOGIN    
  69.     </div>
  70.     <div id="input">
  71.     <form action="" method="post">
  72.        <div>
  73.             <input type="text" name="user" placeholder="Username" class="lg" />
  74.        </div>
  75.        <div style="margin-top: 10px;">
  76.          <input type="password" name="pass" placeholder="Password" class="lg" />
  77.        </div>
  78.        <div style="margin-top: 10px;">
  79.          <input type="submit" name="login" value="login" class="btn" />
  80.        </div>
  81.     </form>
  82.  
  83.     <?php
  84.     $user = @$_POST['user'];
  85.     $pass = @$_POST['pass'];
  86.     $login = @$_POST['login'];
  87.  
  88.     if($login){
  89.     if ($user == "" || $pass == "") {
  90.             ?> <script type="text/javascript">alert("Username/password tidak boleh kosong")</script> <?php
  91.         }else {
  92.             $sql = mysql_query("select * from tb_login where Username = '$user'  and password = md5('$pass')") or die (mysql_error());
  93.             $data= mysql_fetch_array($sql);
  94.             $cek = mysql_num_rows($sql);
  95.             if($cek >= 1) {
  96.                 if ($data['level'] == "admin") {
  97.                     @$_SESSION['admin'] = $data['kode user'];
  98.                     header("location: index.php");
  99.                 }else if ($data['level'] == "operator") {
  100.                     @$_SESSION['operator'] = $data['kode user'];
  101.                     header("location: index.php");
  102.                 }
  103.             } else {
  104.                 echo "login gagal";
  105.             }
  106.         }
  107.     }
  108.     ?>
  109.     </div>
  110. </div>
  111. </body>
  112. </html>                
  113.  
  114. <?php
  115. }
  116. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement