<?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?movienum=5">Click Here to See my Top 5 movies</a>
<br>
<a href="myweb.php?movienum=10">Click Here to See my Top 10 movies</a>
</body>
</html>
And Then…
<?php
// file name : myweb.php
// description : bekerja dengan fungsi
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
function listmovie1(){
echo "1 Life Is Simple<br>";
echo "2 Lupa Ingat<br>";
echo "3 Red Is My Heart<br>";
echo "4 So Close<br>";
echo "5 Terminator<br>";
}
function listmovie2(){
echo "1 Life Is Simple<br>";
echo "2 Lupa Ingat<br>";
echo "3 Red Is My Heart<br>";
echo "4 So Close<br>";
echo "5 Terminator<br>";
echo "6 Anaconda<br>";
echo "7 Si Jago Merah<br>";
echo "8 Ada APa dengan Cinta<br>";
echo "9 Hidup itu mudah<br>";
echo "10 Tidak ada yang abadi<br>";
}
if(isset($_GET['favmovie'])){
echo "Welcome to oursite ";
echo $_SESSION['username']."<br>";
echo "My Favorite Movie is ";
echo $_GET['favmovie'];
}else{
echo "Movies are : <br>";
if($_GET['movienum']==10){
listmovie2();
}else{
listmovie1();
}
}
?>
</body>
</html>
Posting Komentar
Posting Komentar