Vous êtes sur la page 1sur 5

4.

if (isset($_GET['q']) && $_GET['q'] == 1) { = Determine if a variable is set and


is not NULL
if (isset($_COOKIE['test'])) { = An associative array of variables passed to the
current script via HTTP Cookies.
echo 'support'; = untuk menampilkan tulisan support pada layar
} else {
echo 'tidak support';
}

} else {
setcookie('test', 'value'); = defines a cookie to be sent along with the rest of the
HTTP headers. Like other headers, cookies must be sent before any output from
your script (this is a protocol restriction). This requires that you place calls to this
function prior to any output, including <html> and <head> tags as well as any
whitespace.
$self = $_SERVER['PHP_SELF']; = is an array containing information such as
headers, paths, and script locations. The entries in this array are created by the web
server. There is no guarantee that every web server will provide any of these;
servers may omit some, or provide others not listed here. That said, a large number
of these variables are accounted for in the CGI/1.1 specification, so you should be
able to expect those.

//Redireksi ke current script


header ('location: ' . $self . '?q=1');
exit;
}

?>
<p>

<?php

setcookie('nama_cookie', 'nilai_cookie'); = defines a cookie to be sent along


with the rest of the HTTP headers. Like other headers, cookies must be sent before
any output from your script (this is a protocol restriction). This requires that you
place calls to this function prior to any output, including <html> and <head> tags
as well as any whitespace.
if (isset($_COOKIE['nama_cookie'])) {= An associative array of variables passed
to the current script via HTTP Cookies.

echo 'cookie di-set <br/>'; = Output one or more strings

//Menghapus cookie, dengan masa berlaku 3 jam yang lalu


setcookie('nama_cookie', '', time() - 3 * 3600);
echo 'cookie dihapus'; = untuk menampilkan tulisan cookie di hapus pada
layar

}else{
echo 'unset'; = Unset a given variable
}
?>

<p>
Tekan refresh (F5);

<form id="form1" name="form1" method="post"


enctype="multipart/form-data" action="menu.php">
<center style="font-size:24px">Masukkan username dan
Password</center>
<br>
<table style="font-size:16px;color:maroon;" align="center" border="0"
width="100">
<tr> = Tag ini digunakan untuk membuat baris baru

<td width="150" style="font-size:20px">Username</td> = Tag ini


digunakan untuk membuat kolom baru pada tabel.
<td><input type="text" id="username" style="font-size:16px"
name="username" size="20"/></td>
</tr>
<tr>
<td width="150" style="font-size:20px">Password</td>
<td><input type="Password" id="Password" style="font-size:16px"
name="Password" siize="20"/></td>
</tr>
<tr></tr>
<tr>
<td align="center" width="200" colspan="7">
<input class="button_login" type="submit" style="fontsize:16px" name="submit" id="submit" value="Login" />&nbsp;
</tr>
</table>
</form>
</div>
</div>

<body>
<h1>selamat anda telah berhasil login</h1>
<form id="form1" name="form1" method="post"
enctype="multipart/form-data" action="index.php">

<input class="button_logout" type="submit"


style="font-size:16px" name="submit" id="submit"
value="Logout">&nbsp;
</form>
</body>
</html>

<?php
ini_set('display_errors', 1); = Sets the value of a configuration option
define('_VALID', 1); = Defines a named constant

//include file eksternal


require_once('./auth.php'); = The require_once statement is identical to require
except PHP will check if the file has already been included, and if so, not include
(require) it again.

init_login();
validate();

?>
<h3>Simulasi Halaman Admin</h3>
<p>
<a href ="?m=logout">Logout</a>
<p>
Menu-menu admin ada disini
</body>
</html>