Siapa tau ada yang butuh buat pop up login dengan PHP..
1. Code dibawah ini aku letakkin di file browser.php, bisa di modif sesuka hati ya
<style type="text/css">
#loginbox{
margin: 0;
margin-left: 40%;
margin-right: 40%;
margin-top: 50px;
padding-top: 10px;
width: 20%;
height: 150px;
position: absolute;
background: #FBFBF0;
border: solid #000000 2px;
z-index: 9;
font-family: arial;
visibility: hidden;
}
</style>
<script language="JavaScript" type="text/javascript">
function login(showhide){
if(showhide == "show"){
document.getElementById('loginbox').style.visibility="visible";
}else if(showhide == "hide"){
document.getElementById('loginbox').style.visibility="hidden";
}
}
</script>
<div id="loginbox">
<form name="login" action="function/login_process.php?name=login" method="post">
<center>Username:</center>
<center><input name="username" size="20" /></center>
<center>Password:</center>
<center><input name="password" type="password" size="20" /></center>
<center><input type="submit" name="submit" value="LOGIN" /></center>
</form>
<br />
<center><a href="javascript:login('hide');">close</a></center>
</div>
<p><a href="javascript:login('show');">LOGIN</a></p>
2.
nah trus aku buat file untuk memproses login nama nya login_process.php
dan bisa disesuaikan dengan kebutuhan masing-masing ya. :)
<?php
include ('../config/config.php');
session_start();
if ($_GET['name'])
{
$username = $_POST['username'];
$password = $_POST['password'];
// query untuk mendapatkan username dan password dari database
$query = "select * from tbl_user where username = '$username' and password = '$password'";
$hasil = mysqli_query($connection, $query);
if (mysqli_num_rows($hasil) > 0)
{
$_SESSION['username'] = $username;
if ($username == 'admin')
{
header("location:../browser.php?dir=/FILES&&username=admin" );
}
else
{
header("location:../browser.php?dir=/FILES&&username=$username");
}
}
else
{
echo "User tidak terdaftar";
}
}
?>
Kira-kira hasil nya seperti ini setelah kita klik link login
sekian dulu ya, semoga membantu
White
No comments:
Post a Comment