<?php
$user_name= "root";
$password= "";
$database= "dblogin";
$host_name= "localhost";
mysql_connect("localhost","root","");
mysql_select_db("dblogin");
?>
simpan file ditas dengan nama config.php
<?php
session_start();
include 'config.php';
$username=$_POST['username'];
$password=$_POST['password'];
$query=mysql_query("select * from user where username='$username' and password='$password'");
$xxx=mysql_num_rows($query);
if($xxx==TRUE)
{
$_SESSION['username']=$username;
header("location:halaman.php");
}
else
{
echo "gagal login";
}
?>
simpan file diatas dengan nama aksi.php
body
{
background: url(images/princes-pier-269647_960_720.jpg) no-repeat center center fixed;
-webkit-background-size: 100% 100%;
-moz-background-size: 100% 100%;
-o-background-size: 100% 100%;
background-size: 100% 100%;
font-family: Cooper Std Black;
}
#kotak
{
width: 520px;
height: 260px;
background: #FFFFFF;
margin: 150px auto 100px auto;
border: 3px solid #663366;
color:#990066;
}
#atas
{
height: 35px;
width: 520px;
text-align: center;
font-size: 20pt;
padding-top:20px;
}
#bawah
{
height: 200px;
width: 520px;
}
.masuk
{
width: 400px;
height:40px;
margin-top:10px;
margin-left: 60px;
font-size: 12pt;
border: 2px solid #663366;
padding-left:10px;
color:#660033;
}
.masuk:focus
{
width: 400px;
height:40px;
margin-top:10px;
margin-left: 60px;
font-size: 12pt;
padding-left:10px;
color:#660066;
outline: none;
box-shadow: 0 0 20px #FF99FF;
}
#tombol
{
width: 150px;
height:35px;
margin-top:10px;
margin-left: 185px;
background: #660033;
border:none;
color:#fff;
font-size: 11pt;
outline:none;
}
#daftar
{font-family: Book Antiqua;
height: 25px;
width: 520px;
text-align: center;
font-size: 13pt;
padding-top:13px;
}
simpan file diatas dengan nama login.css
<html>
<title> Login </title>
<head>
<link rel="stylesheet" type="text/css" href="login.css">
</head>
<body>
<div id="kotak">
<div id="atas">
LOGIN !
</div>
<div id="bawah">
<form method="post" action="tess.php">
<input class="masuk" type="text" autocomplete="off" placeholder="Username" name="username"><br/>
<input class="masuk" type="password" autocomplete="off" placeholder="Password" name="password"><br/>
<input id="tombol" type="submit" value="LOGIN">
</form>
</div>
</div>
</body>
</html>
simpan file diatas dengan nama login.php
<?php
session_start();
if (empty($_SESSION['username']))
{
header("location:login.php");
}
?>
<html>
<title> Halaman </title>
<body style="background-image:url(images/sky-957877_960_720.jpg)">
<H3> SELAMAT ANDA BERHASIL LOGIN
<?php
echo $_SESSION['username'];
?>
</H3>
<h4><a href="logout.php"> keluar<a> </h4>
</body>
</html>
simpan file diatas dengna nama halaman.php
<?php
session_start(); // memulai session
session_destroy(); // menghapus session
header("location:login.php"); // mengambalikan ke form_login.php
?>
simpan file diatas dengan nama logout.php
keywords : Cara membuat Halaman Login Dengan Session
0 Response to "Cara membuat Halaman Login Dengan Session"
Posting Komentar