Sunday, February 1, 2015

Sintak login di php

FORM LOGIN

<!DOCTYPE html>
<html class="bg-black">
    <head>
        <meta charset="UTF-8">
        <title>Pengawas</title>
        <meta content='width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no' name='viewport'>
        <link href="../css/bootstrap.min.css" rel="stylesheet" type="text/css" />
        <link href="../css/font-awesome.min.css" rel="stylesheet" type="text/css" />
        <link href="../css/AdminLTE.css" rel="stylesheet" type="text/css" />
   <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
          <script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
    </head>

       <body class="bg-black">
<?php
    $msg='';
    isset($_GET['init']) ? $init=$_GET['init']: $init=0;
   switch($init){
        case 1:
        $msg="<p class='btn btn-large btn-danger btn-block' align='center'>login gagal ,periksa user name dan password</p>";
        break;
        case 2:
        $msg="<p class='btn btn-large btn-success btn-block' align='center'>anda berhasil logout </p>";
        break;
        case 3:
        $msg="<p class='btn btn-large btn-warning btn-block' align='center'>Maaf anda belum login , silahkan login terlebih dahulu</p>";
        break;
        case 4:
        $msg="<p class='btn btn-large btn-success btn-block' align='center'><b>Pendaftaran Berhasil <br>Silahkan Cek email dan hubungi administrator</b></p>";
        break;
         case 5:
        $msg="<p class='btn btn-large btn-success btn-block' align='center'><b>Akun anda belum terferifikasi</b></p>";
        break;
   
 
    }
    echo $msg;
    ?>
        <div class="form-box" id="login-box">
            <div class="header">
           <p>Sistem Pengawas Pendidikan</p>
            <p><small>Kabupaten Banjarnegara</small></p>
        </div>
            <form action="login_check.php" method="post">
                <div class="body bg-gray">
                    <div class="form-group">
                        <input type="text" name="id_pengawas" class="form-control" placeholder="NIP" required/>
                    </div>
                    <div class="form-group">
                        <input type="password" name="password" class="form-control" placeholder="Password" required/>
                    </div>        
                    <div class="form-group">
                        <input type="checkbox" name="remember_me"/> Remember me
                    </div>
                </div>
                <div class="footer">                                                            
                    <button type="submit" class="btn bg-olive btn-block">   Masuk</button>
                     <p><a href="../lupa_pass/lostpassword.htm">Lupa Password</a></p>
                     <a href="../register/register.html" class="text-center">Register</a>
                </div>
            </form>      
        </div>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.2/jquery.min.js"></script>
        <script src="../js/bootstrap.min.js" type="text/javascript"></script>      
    </body>
</html>


LOGIN CHCK
<?php
session_start();
include "../koneksi/koneksi.php";
$id_pengawas=$_POST['id_pengawas'];
$password=$_POST['password'];
$pengacak  = 'NDJS3289JSKS190JISJI';
$newPasswordEnkrip = md5($pengacak . md5($_POST['password']) . $pengacak);
$sql="select id_pengawas,password,blok,status  from t_pengawas where id_pengawas='$_POST[id_pengawas]' and password='$newPasswordEnkrip'";
$result=mysql_query($sql,$dbcon);
$data=(mysql_fetch_array($result));
if ($data[blok]==0){
if($id_pengawas == "" || $password == "")
{
header("location:login.php?init=1");
}
else
{
if($newPasswordEnkrip == "$data[password]")
{
$_SESSION['id_pengawas']=$data['id_pengawas'];
$_SESSION['password']=$data['password'];
if ($data['status']==1) {header("location:../administrator/home.php?page=homeadmin");}else { header("location:../home.php?page=homeuser");}}else{header("location:login.php?init=1");}}}else {header("location:login.php?init=5");}?>

No comments:

Post a Comment