kali ini admin akan menjalaskan bagian session login pada administrator DVD
<!DOCTYPE html>
<html lang="en">
<head>
<title>LOGIN ADMIN</title>
<?php include 'linkcss.php'; ?>
<!-- Custom Fonts -->
<link href="font/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">
</head>
<body>
<div class="container">
<div class="row">
<div class="col-md-4 col-md-offset-4">
<div class="login-panel panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">Please Sign In</h3>
</div>
<div class="panel-body">
<form role="form" method="POST" action="proseslogin.php">
<fieldset>
<div class="form-group">
<input class="form-control" placeholder="Username" name="username" type="username" required>
</div>
<div class="form-group">
<input class="form-control" placeholder="Password" name="password" type="password" required>
</div>
<div class="checkbox">
<label>
<input name="remember" type="checkbox" value="Remember Me">Remember Me
</label>
</div>
<!-- Change this to a button or input when using this as a form -->
<button class="btn btn-lg btn-success btn-block">Login</button>
</fieldset>
</form>
</div>
</div>
</div>
</div>
</div>
<!-- jQuery -->
<script src="js/jquery.min.js"></script>
<!-- Bootstrap Core JavaScript -->
<script src="js/bootstrap.min.js"></script>
<!-- Metis Menu Plugin JavaScript -->
<script src="js/metisMenu.min.js"></script>
<!-- Custom Theme JavaScript -->
<script src="js/sb-admin-2.js"></script>
</body>
</html>
coding diatas adalah tampilan html dan script session sebagai berikut
<?php
include "koneksi.php";
$user = $_POST['username'];
$password = $_POST['password'];
$sql = "SELECT * FROM admin WHERE username='$user' AND password='$password'";
$result = ($connect->query($sql));
if($result->num_rows == 1){
$_SESSION['login']= 'true';
header("location:index.php");
}else{
echo "<script>alert('Pastikan Username dan Password benar'); window.location='login.php'</script>";
echo $connect->error;
}
?>
0 komentar:
Posting Komentar