Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- @session_start();
- include "inc/koneksi.php";
- if(@$_SESSION['admin']= $data['kode user'] || @$_SESSION['operator']= $data['kode user']) {
- header("location: index.php");
- } else {
- ?>
- <!DOCTYPE html>
- <html>
- <head>
- <title>HALAMAN LOG IN</title>
- <style type="text/css">
- body{
- font-family: arial;
- font-size: 14px;
- background-color: #222;
- }
- #utama{
- width: 300px;
- margin: 0 auto;
- margin-top: 12%;
- }
- #judul{
- padding: 15px;
- text-align: center;
- color: #fff;
- font-size: 20px;
- background-color: #339966;
- border-top-right-radius: 10px;
- border-top-left-radius: 10px;
- border-bottom: 3px solid #336666;
- }
- #input{
- background-color: #ccc;
- padding: 20px;
- border-bottom-left-radius: 10px;
- border-bottom-right-radius: 10px;
- }
- input {
- padding: 10px;
- border : 0;
- }
- .lg{
- width: 220px
- }
- .btn{
- background-color: #339966;
- border-radius: 10px;
- color: #fff;
- }
- .btn:hover{
- background-color: #336666;
- border-radius: 10px;
- cursor: pointer;
- }
- </style>
- </head>
- <body>
- <div id="utama">
- <div id="judul">
- HALAMAN LOGIN
- </div>
- <div id="input">
- <form action="" method="post">
- <div>
- <input type="text" name="user" placeholder="Username" class="lg" />
- </div>
- <div style="margin-top: 10px;">
- <input type="password" name="pass" placeholder="Password" class="lg" />
- </div>
- <div style="margin-top: 10px;">
- <input type="submit" name="login" value="login" class="btn" />
- </div>
- </form>
- <?php
- $user = @$_POST['user'];
- $pass = @$_POST['pass'];
- $login = @$_POST['login'];
- if($login){
- if ($user == "" || $pass == "") {
- ?> <script type="text/javascript">alert("Username/password tidak boleh kosong")</script> <?php
- }else {
- $sql = mysql_query("select * from tb_login where Username = '$user' and password = md5('$pass')") or die (mysql_error());
- $data= mysql_fetch_array($sql);
- $cek = mysql_num_rows($sql);
- if($cek >= 1) {
- if ($data['level'] == "admin") {
- @$_SESSION['admin'] = $data['kode user'];
- header("location: index.php");
- }else if ($data['level'] == "operator") {
- @$_SESSION['operator'] = $data['kode user'];
- header("location: index.php");
- }
- } else {
- echo "login gagal";
- }
- }
- }
- ?>
- </div>
- </div>
- </body>
- </html>
- <?php
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement