Login : PWD


Login.php

<?php
 include 'dashboard.php'

$username = $_POST['user'];
$password = md5($_POST['pass']);

$query = mysql_query("select * from user where username='$username' and password='$password'");
$cek = mysql_num_rows($query);

if($cek > 0){
                session_start();
                $_SESSION['user'] = $username;
                $_SESSION['status'] = 'login';
                header("location:dashboard.php");
}else{
                header("location:index.php");
}
?>



Keluar.php
<?php

session_start();
session_unset();
session_destroy();

header("Location: index.php");

?>


Index.php
<?php
session_start();
if(isset($_SESSION['username'])){
                header("Location : dashboard.php");
}

?>

<html>
<head>
                <title></title>
</head>
<body>

<form action="login.php" method="POST">
username : <input type="text" name="user"><br>
password : <input type="password" name="pass"><br>

<input type="submit" value="login">
               
                <a h
</form>

</body>
</html>


Dashboard.php
<?php

mysql_connect("localhost","root","");
mysql_select_db("admin");


session_start();
if(!isset($_SESSION['username']))
header("Location: ./");

$username = $_SESSION ["username"];
echo "Anda login sebagai $username <br>";

echo "<a href='keluar.php'>keluar</a>" ;



?>


Previous
Next Post »

Translate