SKRIP LOGIN DAN LOGOUT PADA PHP
Skrip untuk LOGIN
<?php
session_start () ;
error_reporting(0) ;
if (trim($_GET['user]) == 'user_anda' &&trim($_GET['password'])=='password_anda')
{
$_SESSION ['nim'] = 'user_anda' ;
$_SESSION ['unique_id'] = md5 ('user_anda') ;
}
else if (trim($_SESSION['nim'])){
$nim = $_SESSION['nim'] ;
$unique_id = $_SESSION['unique_id'] ;
echo "username anda : ".$nim."<br/>Password : ".$unique_id."<br/><h1>Selamat sudah login<h1>";
}
if ($_SESSION['nim'] == 'user_anda'){echo "untuk keluar klik <a href=logout.php><h2>logout</h2></a>";}
else {
?>
<center>
<form name="form" method="get" action="">Masukkan Username :<input type="text" name="user"><br/>Masukkan Password :<input type="password name="password"></br><input type="submit" value="login" ><input type="reset" value="batal">
</form>
</form>
</center>
<?php } ?>
Skrip untuk LOGOUT
<?php
session_start();
session_unset();
session_destroy();
header('location:login.php');
?>
Skrip untuk LOGOUT
<?php
session_start();
session_unset();
session_destroy();
header('location:login.php');
?>