Script Login | website
Assalamualaikum,,,,Jumpa lagi di postingan ane yg kesekian kali nya, sebelum nya ane posting tentang Script Koneksi ke Database Xampp kali ini kita lanjut kearah lebih tinggi lagi naik satu tingkat :D, pada kali ini saya akan posting tentang Script Login | website masih seputar website gan,,, ini juga perlu gan. ok langsung aja. sebagai berikut:
<?php
include "koneksi.php";
$dari=$_GET['module'];
if($dari=="login") {
$nama=$_POST['nama'];
$sandi=$_POST['sandi'];
if(empty($nama) or empty($sandi)) {
$proses="kosongdata";
} else {
$sql="select * from hakakses where namauser='$nama' and sandi='$sandi'";
$data=mysql_query($sql) or die ("salah sql");
$hasil=mysql_fetch_array($data);
if(empty($hasil['namauser']) or empty($hasil['sandi'])) {
$proses="tolakdata";
} else {
session_start();
session_register("namauser");
session_register("sandi");
session_register("haklevel");
$_SESSION['namauser']=$hasil['namauser'];
$_SESSION['sandi']=$hasil['sandi'];
$_SESSION['haklevel']=$hasil['haklevel'];
header('location:media.php?module=home');
}
}
}
?>
<html>
<head>
<title>login</title>
<style>
#main {
border:ridge;
border-radius:12px;
width:427px;
background-color: #CCFF00;
position:absolute;
left: 427px;
top: 89px;
height: 470px;
}
.style6 {color: #000000}
</style>
</head>
<body>
<div id="main" align="center">
<table width="312" border="1" align="center" cellpadding="0" cellspacing="0">
<tr>
<td></td>
</tr>
<tr>
<td>
<form name="login" method="post" action="?module=login">
<p> </p>
<p><img src="images/bebek7.jpg" width="414" height="243"></p>
<table width="339" border="0" align="center">
<tr>
<td colspan="2"> </td>
</tr>
<tr>
<td width="76"><span class="style6">Nama User</span></td>
<td width="156"><input type="text" name="nama" id="nama" /></td>
</tr>
<tr>
<td><span class="style6">Sandi</span></td>
<td><input type="password" name="sandi" /></td>
</tr>
<tr>
<td colspan="2"><div align="right" class="style6">
<input type="submit" name="submit" value="L O G I N" />
</div></td>
</tr>
<tr>
<td height="20" colspan="2"><span class="style6">
<?php
if($proses=="kosongdata") {
echo "<marquee><font color=#66FFFF>Eror Terjadi Karena Ada Data Yang Kosong</font>";
} elseif($proses=="tolakdata") {
echo "<marquee><font color=#66FFFF>Data Anda Tidak Ditemukan</font>";
} else {
echo "";
}
$proses=="login";
?>
</span></td>
</tr>
</table>
</form></td>
</tr>
</table>
</div>
</body>
</html>
include "koneksi.php";
$dari=$_GET['module'];
if($dari=="login") {
$nama=$_POST['nama'];
$sandi=$_POST['sandi'];
if(empty($nama) or empty($sandi)) {
$proses="kosongdata";
} else {
$sql="select * from hakakses where namauser='$nama' and sandi='$sandi'";
$data=mysql_query($sql) or die ("salah sql");
$hasil=mysql_fetch_array($data);
if(empty($hasil['namauser']) or empty($hasil['sandi'])) {
$proses="tolakdata";
} else {
session_start();
session_register("namauser");
session_register("sandi");
session_register("haklevel");
$_SESSION['namauser']=$hasil['namauser'];
$_SESSION['sandi']=$hasil['sandi'];
$_SESSION['haklevel']=$hasil['haklevel'];
header('location:media.php?module=home');
}
}
}
?>
<html>
<head>
<title>login</title>
<style>
#main {
border:ridge;
border-radius:12px;
width:427px;
background-color: #CCFF00;
position:absolute;
left: 427px;
top: 89px;
height: 470px;
}
.style6 {color: #000000}
</style>
</head>
<body>
<div id="main" align="center">
<table width="312" border="1" align="center" cellpadding="0" cellspacing="0">
<tr>
<td></td>
</tr>
<tr>
<td>
<form name="login" method="post" action="?module=login">
<p> </p>
<p><img src="images/bebek7.jpg" width="414" height="243"></p>
<table width="339" border="0" align="center">
<tr>
<td colspan="2"> </td>
</tr>
<tr>
<td width="76"><span class="style6">Nama User</span></td>
<td width="156"><input type="text" name="nama" id="nama" /></td>
</tr>
<tr>
<td><span class="style6">Sandi</span></td>
<td><input type="password" name="sandi" /></td>
</tr>
<tr>
<td colspan="2"><div align="right" class="style6">
<input type="submit" name="submit" value="L O G I N" />
</div></td>
</tr>
<tr>
<td height="20" colspan="2"><span class="style6">
<?php
if($proses=="kosongdata") {
echo "<marquee><font color=#66FFFF>Eror Terjadi Karena Ada Data Yang Kosong</font>";
} elseif($proses=="tolakdata") {
echo "<marquee><font color=#66FFFF>Data Anda Tidak Ditemukan</font>";
} else {
echo "";
}
$proses=="login";
?>
</span></td>
</tr>
</table>
</form></td>
</tr>
</table>
</div>
</body>
</html>
Silahkan Agan paste script diatas, dan sesuaikan dengan tabel database sobat, kalau disini saya menggunakan Xampp, Sekian Artikel saya kali ini tentang Script Login | website Semoga dapat membantu. baca juga Artikel lain nya Script Koneksi ke Database Xampp
0 on: "Script Login | website"