Disini saya akan membagikan Cara LOGIN PHP MySql dan Desain nya, cie yang lagi belajar PHP serius banget semangat yah, ngoding gampang kok kalo masih tingkat software doang tapi kalo udah nyambung sama hardware itu baru susah. Ok Langsung Ajh saya berikan koding nya, jangan cuman COPAS doang pelajari yah.
Nih Langsung saja kodingnya :
PHP + HTML
<?php
include'config/<a href="http://www.trialanderor.tk/2014/11/membuat-koneksi-databases-mysql-php.html">koneksi.php</a>';
session_start();
echo"
<!DOCTYPE HTML>
<html>
<head>
<title>Belajar Bikin Login di PHP</title>
<link rel='stylesheet' href='css/default.css' type='css/text' media='screen'/>
</head>
<body>
<div id='main-wrapper'>
<div id='header-wrapper'>
<a href='index.php'><img src='img/CGeks.png' height='150px' width='450px'/></a>
</div>
<hr />
<h1 align='center'>BIODATA
</h1>
<div>
<hr />
<label>
<form action='?login_attempt=1' method='post' name='login'>
<p><input id='email' name='id_user' type='text' placeholder='Username' style='background: #eee url(img/username.png) no-repeat 8px 12px;'/></p>
<p><input id='password' name='password' type='password' placeholder='Password' style='background: #eee url(img/password.png) no-repeat 8px 12px;'/></p>
<p><input id='submit' type='submit' name='Login' value='Login'/></p>
</form>
</label>
</div>
<br/>
<div id='footer'>
Created by <a href='http://www.trialanderor.tk' target='_blank'>Trial And Eror</a>
</div>
</div>
</body>
</html>";
if(isset($_GET['login_attempt'])){
$id_user=$_POST['id_user'];
$pass=md5($_POST['password']);
$cek=mysql_query("SELECT*FROM user WHERE id_user='$id_user' AND password='$pass'");
$row=mysql_fetch_array($cek);
$hasil=mysql_num_rows($cek);
if($hasil==1){
$_SESSION['loginhast']=$row[id_user];
$_SESSION['nama']=$row[nama];
$_SESSION['level']=$row[level];
header("location:biodata.php?page=beranda");
}else{
echo"<script>alert('Username atau Password Salah...!');window.location='#login_attempt=1'; </script>";
}
}
?>
include'config/<a href="http://www.trialanderor.tk/2014/11/membuat-koneksi-databases-mysql-php.html">koneksi.php</a>';
session_start();
echo"
<!DOCTYPE HTML>
<html>
<head>
<title>Belajar Bikin Login di PHP</title>
<link rel='stylesheet' href='css/default.css' type='css/text' media='screen'/>
</head>
<body>
<div id='main-wrapper'>
<div id='header-wrapper'>
<a href='index.php'><img src='img/CGeks.png' height='150px' width='450px'/></a>
</div>
<hr />
<h1 align='center'>BIODATA
</h1>
<div>
<hr />
<label>
<form action='?login_attempt=1' method='post' name='login'>
<p><input id='email' name='id_user' type='text' placeholder='Username' style='background: #eee url(img/username.png) no-repeat 8px 12px;'/></p>
<p><input id='password' name='password' type='password' placeholder='Password' style='background: #eee url(img/password.png) no-repeat 8px 12px;'/></p>
<p><input id='submit' type='submit' name='Login' value='Login'/></p>
</form>
</label>
</div>
<br/>
<div id='footer'>
Created by <a href='http://www.trialanderor.tk' target='_blank'>Trial And Eror</a>
</div>
</div>
</body>
</html>";
if(isset($_GET['login_attempt'])){
$id_user=$_POST['id_user'];
$pass=md5($_POST['password']);
$cek=mysql_query("SELECT*FROM user WHERE id_user='$id_user' AND password='$pass'");
$row=mysql_fetch_array($cek);
$hasil=mysql_num_rows($cek);
if($hasil==1){
$_SESSION['loginhast']=$row[id_user];
$_SESSION['nama']=$row[nama];
$_SESSION['level']=$row[level];
header("location:biodata.php?page=beranda");
}else{
echo"<script>alert('Username atau Password Salah...!');window.location='#login_attempt=1'; </script>";
}
}
?>
CSS
*{
margin:0; padding:0;
font-family:calibri, ‚segoe ui?, arial, tahoma, sans-serif;
}
body{
background: #f0f0f0 ;
}
#main-wrapper{
margin: 0 auto;
margin-top: 80px;
padding: 20px;
width: 450px;
background-color: white;
border: silver solid;
border-radius: 10px 10px 10px 10px;
}
#header-wrapper{
width: 100%;
margin: 0 auto;
}
#navigasi{
width: 100%;
margin: 0 auto;
}
ul{
background-color: brown;
}
ul li{
list-style-type:none;
list-style:none
}
li{
float: left;
padding: 5px;
border-right: 5px;
}
#footer{
clear:both;
margin-top:20px;
text-align:center;
background-color: #ccc;
padding:5px; color:#555555;
text-decoration: none;
}
input {
width: 100%; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box;
padding: 10px; min-height: 44px; font-size: 14px !important; border: 0; color: #999;
background: #eee; padding-left: 30px;
}
input#submit{
padding: 12px 0;
border: 0;
text-transform: uppercase;
font-size: 13px;
text-shadow: 1px 1px rgba(0,0,0,0.2);
box-shadow: 0 2px 3px rgba(0,0,0,0.3);
}
margin:0; padding:0;
font-family:calibri, ‚segoe ui?, arial, tahoma, sans-serif;
}
body{
background: #f0f0f0 ;
}
#main-wrapper{
margin: 0 auto;
margin-top: 80px;
padding: 20px;
width: 450px;
background-color: white;
border: silver solid;
border-radius: 10px 10px 10px 10px;
}
#header-wrapper{
width: 100%;
margin: 0 auto;
}
#navigasi{
width: 100%;
margin: 0 auto;
}
ul{
background-color: brown;
}
ul li{
list-style-type:none;
list-style:none
}
li{
float: left;
padding: 5px;
border-right: 5px;
}
#footer{
clear:both;
margin-top:20px;
text-align:center;
background-color: #ccc;
padding:5px; color:#555555;
text-decoration: none;
}
input {
width: 100%; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box;
padding: 10px; min-height: 44px; font-size: 14px !important; border: 0; color: #999;
background: #eee; padding-left: 30px;
}
input#submit{
padding: 12px 0;
border: 0;
text-transform: uppercase;
font-size: 13px;
text-shadow: 1px 1px rgba(0,0,0,0.2);
box-shadow: 0 2px 3px rgba(0,0,0,0.3);
}
Thanks infonya gan :D
ReplyDeleteIjin bookmark dulu..php ane masih awam gan..
ReplyDelete