<?php
error_reporting (0);
$host='localhost';
$user='root';
$pass='';
$conn=mysql_connect($host,$user,$pass);
mysql_select_db('coba',$conn)or die('gagal konek');
session_start();
if($_POST['login'])
{
$username=$_POST['username'];
$password=$_POST['password'];
$query='select * from user where username="'.$username.'" and password="'.$password.'"';
$result=mysql_query($query);
$hasil=mysql_num_rows($result);
if($hasil>0)
{
$_SESSION['username']=$username;
header('location:http://safriansah.blogspot.com/');
}
else
{
echo"login error <a href='login.php'>BACK</a>";
}
}
?>
<form method='post'>
<table>
<tr>
<td>Username</td>
<td>: <input type='text' name='username' maxlength='20'></td>
</tr>
<tr>
<td>Password</td>
<td>: <input type='password' name='password' maxlength='20'></td>
</tr>
<tr>
<td colspan='2' align='right'><input type='submit' name='login' value='LOGIN'></td>
</tr>
</table>
</form>
Contoh Code Login PHP
Reviewed by Syafriansyah Muhammad
on
2/27/2015
Rating:
Tidak ada komentar: