<?php
// file name : header.php
// description : membuat file header
?>
<div style="text-align:center">
<p>Welcome to my movie review site</p>
<?php
date_default_timezone_set("Beijing/Hongkong");
echo "Today Is ";
echo date("F d");
echo ",";
echo date("Y");
?>
<br>
</div>
And then..
<?php
// file name : website.php
// description : bekerja dengan fungsi
session_start();
$_SESSION['username']=$_POST['user'];
$_SESSION['userpass']=$_POST['pass'];
$_SESSION['authuser']=0;
if(($_SESSION['username']='kenzu') and ($_SESSION['userpass']='200491')){
$_SESSION['authuser']=1;
}
else{
echo "Sorry, You don't have permission to access this page";
exit();
}
?>
<html>
<head>
<title>my effort is coding</title>
</head>
<body>
<?php
$mymovie=urlencode('life is simple');
echo "<a href="myweb.php?favmovie=$mymovie">";
echo "click here to see information about my favorite movie";
echo "</a>";
?>
<br>
<a href="myweb.php">Click Here to See my Top 10 movies</a>
<br>
<a href="myweb.php?sorted=true">Click Here to See my Top 10 movies sorted alphabetically</a>
</body>
</html>
And then..
<?php
// file name : myweb.php
// description : bekerja dengan array
session_start();
if($_SESSION['authuser']!=1){
echo "sorry guys u can't access this page<br>";
exit();
}
?>
<html>
<head>
<title>my movie -
<?php
if(isset($_GET['favmovie'])){
echo "-";
echo $_GET['favmovie'];
}
?>
</title>
</head>
<body>
<?php include "header.php"; ?>
<?php
$favmovie=array("Life Is Simple",
"Anindya Fitri",
"Red Is My Heart",
"So Close",
"Terminator",
"Anaconda",
"Si Jago Merah",
"Ada Apa Dengan Cinta",
"Hidup Itu Mudah",
"Tidak Ada Yang Abadi");
if(isset($_GET['favmovie'])){
echo "Welcome to oursite ";
echo $_SESSION['username']."<br>";
echo "My Favorite Movie is ";
echo $_GET['favmovie'];
}else{
echo "My Top 10 Favorite Movies are : <br>";
if(isset($_GET['sorted'])){
sort($favmovie);
}
echo "<ol>";
foreach($favmovie as $movie){
echo "<li>";
echo $movie;
echo "</li>";
}
echo "</ol>";
}
?>
</body>
</html>
Posting Komentar
Posting Komentar