Sunday, September 14, 2008

PHP Script to Send Html Email

<?php

// Example

$HTML = "

<span style=\"color:#FF0000; font-size:22px; font-weight:bold;\">This is a test send html e-mail</span>

";

$from = "abc@yahoo.com";

$to = "your_email@yahoo.com";

$subject = "I'm sending a test HTML email";

sendHTMLemail($HTML,$from,$to,$subject);function sendHTMLemail($HTML,$from,$to,$subject)

{

// First we have to build our email headers

// Set out "from" address

$headers = "From: $from\r\n";

// Now we specify our MIME version

$headers .= "MIME-Version: 1.0\r\n";

// Create a boundary so we know where to look for

// the start of the data

$boundary = uniqid("HTMLEMAIL");

// First we be nice and send a non-html version of our email

$headers .= "Content-Type: multipart/alternative;".

"boundary = $boundary\r\n\r\n";

$headers .= "This is a MIME encoded message.\r\n\r\n";

$headers .= "--$boundary\r\n".

"Content-Type: text/plain; charset=ISO-8859-1\r\n".

"Content-Transfer-Encoding: base64\r\n\r\n";

$headers .= chunk_split(base64_encode(strip_tags($HTML)));

// Now we attach the HTML version

$headers .= "--$boundary\r\n".

"Content-Type: text/html; charset=ISO-8859-1\r\n".

"Content-Transfer-Encoding: base64\r\n\r\n";

$headers .= chunk_split(base64_encode($HTML));

// And then send the email ....

mail($to,$subject,"",$headers);

echo("email has been sent...!");

}

?>

Friday, April 11, 2008

Quick Menu with CSS

1. Letakkan CSS dibawah ini diantara tag <HEAD>

<!--%%%%%%%%%%%% QuickMenu Styles [Keep in head for full validation!] %%%%%%%%%%%-->

<style type="text/css">

/*!!!!!!!!!!! QuickMenu Core CSS [Do Not Modify!] !!!!!!!!!!!!!*/

.qmmc .qmdivider{display:block;font-size:1px;border-width:0px;border-style:solid;position:relative;z-index:1;}.qmmc .qmdividery{float:left;width:0px;}.qmmc .qmtitle{display:block;cursor:default;white-space:nowrap;position:relative;z-index:1;}.qmclear {font-size:1px;height:0px;width:0px;clear:left;line-height:0px;display:block;float:none !important;}.qmmc {position:relative;zoom:1;z-index:10;}.qmmc a, .qmmc li {float:left;display:block;white-space:nowrap;position:relative;z-index:1;}.qmmc div a, .qmmc ul a, .qmmc ul li {float:none;}.qmsh div a {float:left;}.qmmc div{visibility:hidden;position:absolute;}.qmmc .qmcbox{cursor:default;display:block;position:relative;z-index:1;}.qmmc .qmcbox a{display:inline;}.qmmc .qmcbox div{float:none;position:static;visibility:inherit;left:auto;}.qmmc li {z-index:auto;}.qmmc ul {left:-10000px;position:absolute;z-index:10;}.qmmc, .qmmc ul {list-style:none;padding:0px;margin:0px;}.qmmc li a {float:none}.qmmc li:hover>ul{left:auto;}#qm0 ul {top:100%;}#qm0 ul li:hover>ul{top:0px;left:100%;}

/*!!!!!!!!!!! QuickMenu Styles !!!!!!!!!!!*/

/* QuickMenu 0 */

/*"""""""" (MAIN) Container""""""""*/

#qm0
{
width:auto;
padding:5px 10px 5px 10px;
background-color:#EFEFEF;
border-width:10px 1px 1px 1px;
border-style:solid;
border-color:#4D4D4D;
}

/*"""""""" (MAIN) Items""""""""*/

#qm0 a
{
padding:3px 40px 3px 8px;
color:#222222;
font-family:Arial;
font-size:12px;
text-decoration:none;
border-width:1px;
border-style:dashed;
border-color:#EFEFEF;
}

/*"""""""" (MAIN) Hover State""""""""*/

#qm0 a:hover
{
text-decoration:underline;
}

/*"""""""" (MAIN) Hover State - (duplicated for pure CSS)""""""""*/
#qm0 li:hover>a
{
text-decoration:underline;
}

/*"""""""" (MAIN) Active State""""""""*/

body #qm0 .qmactive, body #qm0 .qmactive:hover
{
background-color:#4D4D4D;
color:#EFEFEF;
text-decoration:underline;
}

/*"""""""" (SUB) Container""""""""*/

#qm0 div, #qm0 ul
{
padding:10px;
margin:-1px 0px 0px 0px;
background-color:#EFEFEF;
border-width:1px;
border-style:solid;
border-color:#4D4D4D;
}

/*"""""""" (SUB) Items""""""""*/

#qm0 div a, #qm0 ul a
{
padding:1px 40px 2px 5px;
font-size:11px;
border-width:1px 0px 1px 0px;
border-style:dashed;
border-color:#EFEFEF;
}

/*"""""""" Individual Titles""""""""*/

#qm0 .qmtitle
{
margin:2px 5px 5px 5px;
color:#222222;
font-family:Arial;
font-size:11px;
font-weight:bold;
}

/*"""""""" Individual Horizontal Dividers""""""""*/

#qm0 .qmdividerx
{
border-top-width:1px;
margin:4px 5px 4px 5px;
border-color:#999999;
}

/*"""""""" Custom Rule""""""""*/

ul#qm0 ul .qmparent
{
background-image:url(qmimages/arrow_5.gif);
}

/*"""""""" Custom Rule""""""""*/

ul#qm0 .qmparent
{
background-image:url(qmimages/arrow_7.gif);
background-repeat:no-repeat;
background-position:95% 55%;
}

/*"""""""" Custom Rule""""""""*/

ul#qm0 li:hover > a.qmparent
{
background-color:#4D4D4D;
color:#EFEFEF;
}

</style>

2. Letakkan code dibawah ini diantara tag <HEAD>

<ul id="qm0" class="qmmc">
<li><a class="qmparent" href="javascript:void(0)">Solutions</a>
<ul>
<li><span class="qmtitle" >Industries</span></li>
<li><a href="javascript:void(0)">Education</a></li>
<li><a class="qmparent" href="javascript:void(0)">Financial Services &nbsp; &nbsp; =></a>
<ul>
<li><a href="javascript:void(0)">Government</a></li>
<li><a href="javascript:void(0)">Manufacturing</a></li>
<li><a href="javascript:void(0)">Locations</a></li>
<li><a href="javascript:void(0)">Tech. Lending</a></li>
</ul></li>
<li><a href="javascript:void(0)">Government</a></li>
<li><a href="javascript:void(0)">Manufacturing</a></li>
<li><a href="javascript:void(0)">Telecom Services</a></li>
<li><span class="qmdivider qmdividerx" ></span></li>
<li><span class="qmtitle" >Solutions</span></li>
<li><a href="javascript:void(0)">Digital Imaging</a></li>
<li><a href="javascript:void(0);">Mobil</a></li>
<li><a href="javascript:void(0);">Print Publishing</a></li>
<li><a href="javascript:void(0);">Rich Internet Applications</a></li>
<li><a href="javascript:void(0);">Training and eLearning</a></li>
<li><a href="javascript:void(0);">Video and Audio</a></li>
<li><a href="javascript:void(0);">Web Conferencing</a></li>
<li><a href="javascript:void(0);">Web Publishing</a></li>
<li><span class="qmdivider qmdividerx" ></span></li>
<li><a href="javascript:void(0);">All Industries and Solutions</a></li>
</ul></li>
<li><a class="qmparent" href="javascript:void(0)">Products</a>
<ul>
<li><a href="javascript:void(0)">Acrobat Connect</a></li>
<li><a href="javascript:void(0)">Acrobat Family</a></li>
<li><a href="javascript:void(0)">After Effects</a></li>
<li><a href="javascript:void(0)">Cold Fusion</a></li>
<li><a href="javascript:void(0)">Creative Suite Family</a></li>
<li><a href="javascript:void(0)">Dreamweaver</a></li>
<li><a href="javascript:void(0);">Flash</a></li>
<li><a href="javascript:void(0);">Flex</a></li>
<li><a href="javascript:void(0);">Illustrator</a></li>
<li><a href="javascript:void(0);">LiveCycle Enterprise Suite</a></li>
<li><a href="javascript:void(0);">Mobile Products</a></li>
<li><a href="javascript:void(0);">Photoshop Family</a></li>
<li><a href="javascript:void(0);">Premiere</a></li>
<li><span class="qmdivider qmdividerx" ></span></li>
<li><a href="javascript:void(0);">All Products</a></li>
</ul></li>
<li><a class="qmparent" href="javascript:void(0)">Support</a>
<ul>
<li><a href="javascript:void(0)">Support Home</a></li>
<li><a href="javascript:void(0)">Customer Service</a></li>
<li><a href="javascript:void(0)">Knowledge Base</a></li>
<li><a href="javascript:void(0)">Books</a></li>
<li><a href="javascript:void(0)">Training and Certification</a></li>
<li><a href="javascript:void(0)">Support Programs</a></li>
<li><a href="javascript:void(0);">Forums</a></li>
<li><a href="javascript:void(0);">Documentation</a></li>
<li><a href="javascript:void(0);">Updates</a></li>
<li><span class="qmdivider qmdividerx" ></span></li>
<li><a href="javascript:void(0);">More</a></li>
</ul></li>
<li><a class="qmparent" href="javascript:void(0)">Communities</a>
<ul>
<li><span class="qmtitle" >By User</span></li>
<li><a href="javascript:void(0)">Graphic Designers</a></li>
<li><a href="javascript:void(0)">Web Developers</a></li>
<li><a href="javascript:void(0)">Educators</a></li>
<li><a href="javascript:void(0)">Partners</a></li>
<li><span class="qmdivider qmdividerx" ></span></li>
<li><span class="qmtitle" >By Resource</span></li>
<li><a href="javascript:void(0)">Adobe Labs</a></li>
<li><a href="javascript:void(0)">Technical Forums</a></li>
<li><a href="javascript:void(0);">Idea Exchange</a></li>
<li><a href="javascript:void(0);">Blogs</a></li>
</ul></li>
<li><a class="qmparent" href="javascript:void(0);">Company</a>
<ul>
<li><a href="javascript:void(0);">About Adobe</a></li>
<li><a href="javascript:void(0);">Press</a></li>
<li><a href="javascript:void(0);">Investor Relations</a></li>
<li><a href="javascript:void(0);">Corporate Affairs</a></li>
<li><a href="javascript:void(0);">Jobs</a></li>
<li><a href="javascript:void(0);">Showcase</a></li>
<li><a href="javascript:void(0);">Events</a></li>
<li><a href="javascript:void(0);">Contact Adobe</a></li>
<li><a href="javascript:void(0);">Become an Affiliate</a></li>
<li><span class="qmdivider qmdividerx" ></span></li>
<li><a href="javascript:void(0);">More</a></li>
</ul></li>
<li class="qmclear">&nbsp;</li></ul>
<!-- Create Menu Settings: (Menu ID, Is Vertical, Show Timer, Hide Timer, On Click ('all', 'main' or 'lev2'), Right to Left, Horizontal Subs, Flush Left, Flush Top) -->
<script type="text/javascript">qm_create(0,false,0,500,false,false,false,false,false);</script>



----- Selamat Mencoba -----

CSS Scrolling Text

1. Letakkan CSS di bawah ini di antara tag <HEAD>

<style type="text/css">
<!--
#mycustomscroll2 {
/* Typical fixed height and fixed width example */
width: 550px;
height: 550px;
overflow: auto;
/* IE overflow fix, position must be relative or absolute*/
position: relative;
margin: 0px;
padding: 0px;
text-align:left;
}
-->
</style>

2. Letakkan code di bawah ini di antara tag <BODY>

<div id='mycustomscroll2' >
<table width="90%" border="0" cellpadding="0" cellspacing="10" align="left">
<tr><td gt;<strong>Terms and Conditions</strong></td></tr>
<tr><td>
<strong>$500 minimum order</strong><br />
12pc/min per style, 6pc/min per color<br />
average production turn around time is 4-8weeks<br />
Coral Reef garments are custom made for all customers (sorry no generic stock available!)<br />
Aggro Pacific requires a 20% commitment deposit before processing any order, 80% balance is due when goods are ship ready. Commitment deposits are non refundable once production has started.<br /><br />

<strong>Payment methods:</strong><br />
Company checks/ chasiers check/ bank wire/ major credit cards (amex, visa, mastercard) are all accepted<br />
Major corporate accounts,: (Deposits and payment methods negotiable)<br /><br />

<strong>Name Drop policy:</strong><br />
All name drop orders placed with Aggro Pacific are custom cut and sewn to order.<br />
Minimum: 48pcs per design per color<br />
Minimum: 24pcs per body style<br />
A 40% deposit is required for name drop orders to be processed.<br /><br />

<strong>Custom silkscreening & Embroidery services:</strong><br />
<strong>Art work set up fees:</strong><br />
A One time fee of $20 per original design (includes up to a 2 color images for silkscreen or emb.) or any of our Coral Reef generic designs.<br />
Logos, names and art work must be provided in pdf format.<br /><br />

<strong>Silkscreen & Embroidery production:</strong><br />
A minimal fee of $1.00 will be applied to allgarments with custom name drop/logo.<br />
***choose any of Coral Reef's generic design and we will name drop under existing art work to customize your garment.<br /><br />

<strong>Custom labeling:</strong><br />
Aggro Pacific also specializes in custom hang tags and label production<br />
Minimum order hang tags: 1000pcs<br />
Minimum order satin labels: 1000pcs<br />
Minimum order woven labels: 3000pcs<br />
Logos, names and art work must be provided in pdf format<br /><br />

<strong>Return policy:</strong><br />
all damages must be reported via fax or email within 10days upon receipt of order. All goods returned to Aggro Pacific must have RA numbers assigned by Aggro Pacific before returns will be accepted. Defective items will be credited back as well as shipping charges for the returned within 30days.<br /><br />

<strong>Shipping shortages:</strong><br />
Any goods missing from the packing list enclosed with your shipment must be reported immedietely to Aggro Pacific within 7 days.<br />
</td></tr>
</table>
</div>

PHP Script Booking Status


1. Buat database

CREATE TABLE reservation (
id_r int(10) NOT NULL auto_increment,
name varchar(30) NOT NULL default '',
email varchar(70) NOT NULL default '',
type_villa char(1) NOT NULL default '',
d1 char(2) NOT NULL default '',
m1 char(2) NOT NULL default '',
y1 varchar(4) NOT NULL default '',
d2 char(2) NOT NULL default '', m2 char(2) NOT NULL default '',
y2 varchar(4) NOT NULL default '', status char(1) NOT NULL default '',
PRIMARY KEY (id_r) ) TYPE=MyISAM;


# # Dumping data for table `reservation` #


INSERT INTO reservation VALUES (29, 'made nawi', 'kuthonkerokan@yahoo.com', '2', '29', '09', '2008', '29', '09', '2008', '0');
INSERT INTO reservation VALUES (23, 'made nawi', 'nawi@yahoo.com.sg', '3', '10', '04', '2008', '19', '04', '2008', '1');
INSERT INTO reservation VALUES (24, 'nawi', 'nawi@yahoo.com.sg', '1', '09', '08', '2008', '20', '08', '2008', '0');
INSERT INTO reservation VALUES (25, 'nawi', 'nawi@yahoo.com.sg', '3', '20', '05', '2008', '30', '05', '2008', '0');
INSERT INTO reservation VALUES (26, 'made nawi', 'nawi@yahoo.com.sg', '2', '08', '05', '2008', '14', '09', '2008', '1');
INSERT INTO reservation VALUES (27, 'made nawi', 'kuthonkerokan@yahoo.com', '1', '14', '04', '2008', '11', '05', '2008', '0');
INSERT INTO reservation VALUES (28, 'made nawi', 'kuthonkerokan@yahoo.com', '2', '02', '04', '2008', '30', '04', '2008', '0');

CREATE TABLE villa (    
id_villa int(1) NOT NULL auto_increment,
villa varchar(30) NOT NULL default '',
PRIMARY KEY (id_villa) ) TYPE=MyISAM;


# # Dumping data for table `villa` #
INSERT INTO villa VALUES (1, 'level 1 - single room 1');
INSERT INTO villa VALUES (2, 'level 1 - single room 2');
INSERT INTO villa VALUES (3, 'level 1 - couple room');
INSERT INTO villa VALUES (4, 'level 2 - superior room 1');
INSERT INTO villa VALUES (5, 'level 2 - superior room 2');



2. Buat file 'koneksi.php'

<?php
function open_connection()
{
$host="localhost";
$username="";
$password="";
$databasename="gecko";
$link=mysql_connect($host,$username,$password) or die ("Database tidak dapat dihubungkan!");
mysql_select_db($databasename,$link);
return ($link);
}
?>

4. File 'send_reservation.php'

<?php
require("koneksi.php");
$link=open_connection();
?>

<html>
<head>
<title></title>
</head>
<body bgcolor="#EDF6CD">

<table width="420" border="0" cellspacing="0" cellpadding="5">
<tr>
<td>
<?php

//----lihat kebenaran pengisian form reservation//
$th_skr=date("Y");
$bln_skr=date("m");
$tgl_skr=date("d");

$gagal="0";

echo("<font color='#ff0000' size='4'>");

//---validasi check in
if($arr_year < $th_skr){
$gagal="1";
echo("Invalid check-in date !");
exit;
}elseif($arr_year == $th_skr){

if($arr_month < $bln_skr){
$gagal="1";
echo("Invalid check-in date !");
exit;
}elseif($arr_month == $bln_skr){

if($arr_date < $tgl_skr){
$gagal="1";
echo("Invalid check-in date !");
exit;
}

}

}

//---validasi check out---

if($dep_year < $arr_year){
$gagal="1";
echo("Invalid check-out date !");
exit;
}elseif($dep_year == $arr_year){

if($dep_month < $arr_month){
$gagal="1";
echo("Invalid check-out date !");
exit;
}elseif($dep_month == $arr_month){

if($dep_date < $arr_date){
$gagal="1";
echo("Invalid check-out date !");
exit;
}



}

}

//--validasi empty room---

$cr_kmr=mysql_query("SELECT * FROM reservation WHERE type_villa = '$villa' AND (

(

( y1='$arr_year' AND y2='$arr_year' ) AND

( m1='$arr_month' AND m2='$arr_month' ) AND

( ( d1<'$arr_date' OR d1='$arr_date') AND ( d2>'$arr_date' OR d2='$arr_date' ) )

) OR

(

( y1='$dep_year' AND y2='$dep_year' ) AND

( m1='$dep_month' AND m2='$dep_month' ) AND

( ( d1<'$dep_date' OR d1='$dep_date') AND ( d2>'$dep_date' OR d2='$dep_date' ) )

) OR

(

( y1='$arr_year' AND y2='$arr_year' ) AND

( m1='$arr_month' AND m2>'$arr_month' ) AND

( d1<'$arr_date' OR d1='$arr_date' )

) OR

(

( y1='$dep_year' AND y2='$dep_year' ) AND

( m1='$dep_month' AND m2>'$dep_month' ) AND

( d1<'$dep_date' OR d1='$dep_date' )

) OR

(

( y1='$arr_year' AND y2='$arr_year' ) AND

( m1<'$arr_month' AND m2>'$arr_month' )

) OR

(

( y1='$dep_year' AND y2='$dep_year' ) AND

( m1<'$dep_month' AND m2>'$dep_month' )

) OR

(

( y1='$arr_year' AND y2='$arr_year' ) AND

( m1<'$arr_month' AND m2='$arr_month' ) AND

( d2>'$arr_date' OR d2='$arr_date' )

) OR

(

( y1='$dep_year' AND y2='$dep_year' ) AND

( m1<'$dep_month' AND m2='$dep_month' ) AND

( d2>'$dep_date' OR d2='$dep_date' )

) OR

(

( y1='$arr_year' AND y2>'$arr_year' ) AND

( m1='$arr_month' ) AND

( d1<'$arr_date' OR d1='$arr_date' )

) OR

(

( y1='$dep_year' AND y2>'$dep_year' ) AND

( m1='$dep_month' ) AND

( d1<'$dep_date' OR d1='$dep_date' )

) OR

(

( y1='$arr_year' AND y2>'$arr_year' ) AND

( m1<'$arr_month' )

) OR

(

( y1='$dep_year' AND y2>'$dep_year' ) AND

( m1<'$dep_month' )

) OR

(

( y1<'$arr_year' AND y2>'$arr_year')

) OR



(



( y1<'$dep_year' AND y2>'$dep_year')



) OR





(



( y1<'$arr_year' AND y2='$arr_year' ) AND



( m2='$arr_month' ) AND



( d2>'$arr_date' OR d2='$arr_date' )



) OR



(



( y1<'$dep_year' AND y2='$dep_year' ) AND



( m2='$dep_month' ) AND

( d2>'$dep_date' OR d2='$dep_date' )

) OR

(

( y1<'$arr_year' AND y2='$arr_year' ) AND

( m2>'$arr_month' )

) OR

(

( y1<'$dep_year' AND y2='$dep_year' ) AND

( m2>'$dep_month' )

)

)") or die(mysql_error());

$jml_cr=mysql_num_rows($cr_kmr);

if($jml_cr > 0){
$gagal="1";
echo("Sorry, the period you are requesting has been reserved for this room.");
exit;
}

////////////////////////////

echo("</font>");
if($gagal=="0"){

$cr_villa=mysql_query("SELECT * FROM villa WHERE id_villa = $villa") or die(mysql_error());
$req_villa=mysql_fetch_array($cr_villa);
$villa_name=$req_villa['villa'];

$pesan= "
Name : $realname
Address : $address
Telephone no. : $phone
E-mail : $email
Type of villa : $villa_name
No. of guest : $guest
Checkin (Arrival date) : $arr_date - $arr_month - $arr_year
Checkout (Departure date) : $dep_date - $dep_month - $dep_year
Special Request : $comments
";

//--------email ke Admin--------
//echo("pesan ::::: $pesan");

$sql_ins=mysql_query("INSERT INTO reservation (name, email, type_villa, d1, m1, y1, d2, m2, y2, status) VALUES ('$realname', '$email', '$villa', '$arr_date', '$arr_month', '$arr_year', '$dep_date', '$dep_month', '$dep_year', '0')") or die(mysql_error());

?>
<div align="center">
<font size="+2">Thank you for your reservation.<p></p>We will get back to you as soon as possible.<p></p>Please make respective payment.<br><br>Total cost of your booking:

<?php
$d1="$arr_date";
$m1="$arr_month";
$y1="$arr_year";
$d2="$dep_date";
$m2="$dep_month";
$y2="$dep_year";

//--kemungkinan 1 bulan in = bulan out AND tahun in = tahun out ---> m1=m2 AND y1=y2

if($m1=="$m2" AND $y1="$y2"){

for($k=$d1; $k<$d2+1; $k++){
$kkk++;
$tgl="$k-$m1-$y1=$status";
//echo("$tgl<br>");
$list_tgl="$list_tgl;$tgl";
}

}
//--kemungkinan 2 bulan out > bulan in AND tahun in = tahun out ---> m2>m1 AND y1=y2
if($m2 > $m1 AND $y1=="$y2"){
$selisihbulan=$m2-$m1;
$keluar1="0";
$keluar3="0";

for($mm1=$m1; $mm1<$m2+1; $mm1++){
$jml_hari = date('t',mktime(0,0,0,$mm1,1,$y1)); // This is to calculate number of days in a month

if($keluar1=="0"){
$keluar1="1";
for($k2=$d1; $k2<$jml_hari+1; $k2++){
$tgl="$k2-$m1-$y1=$status";
$list_tgl="$list_tgl;$tgl";
}

}



if($selisihbulan > 1 AND $mm1<$m2 AND $mm1>$m1){
for($kkk2=1; $kkk2<$jml_hari+1; $kkk2++){
$tgl="$kkk2-$mm1-$y1=$status";
$list_tgl="$list_tgl;$tgl";
}

}

if($keluar3=="0"){
$keluar3="1";
for($kk2=1; $kk2<=$d2; $kk2++){
$tgl="$kk2-$m2-$y1=$status";
$list_tgl="$list_tgl;$tgl";
}

}

}

}

//----kemungkinan 3 : tahun out > tahun in ------- >

if($y2 > $y1){
$selisihtahun=$y2-$y1;
$selisihbulanthpertama=12-$m1;
$keluary1="0";
$keluary2="0";

for($yy1=$y1; $yy1<$y2+1; $yy1++){

for($mmm1=1; $mmm1<13; $mmm1++){
$jml_hari = date('t',mktime(0,0,0,$mmm1,1,$yy1)); // This is to calculate number of days in a month

if($keluary1=="0"){
$keluary1="1";
for($k3=$d1; $k3<$jml_hari+1; $k3++){
$tgl="$k3-$m1-$y1=$status";
$list_tgl="$list_tgl;$tgl";
}

}

if($selisihbulanthpertama > 1 AND $mmm1<13 AND $mmm1>$m1 AND $yy1=="$y1"){

for($kkk3=1; $kkk3<$jml_hari+1; $kkk3++){
$tgl="$kkk3-$mmm1-$y1=$status";
$list_tgl="$list_tgl;$tgl";
}
}

if($selisihtahun > 1 AND $yy1 > $y1 AND $yy1 < $y2){

for($kkkkk3=1; $kkkkk3<$jml_hari+1; $kkkkk3++){
$tgl="$kkkkk3-$mmm1-$yy1=$status";
$list_tgl="$list_tgl;$tgl";
}

}

if($m2 > 1 AND $mmm1<$m2 AND $mmm1>0 AND $yy1=="$y2"){

for($kkkk3=1; $kkkk3<$jml_hari+1; $kkkk3++){

$tgl="$kkkk3-$mmm1-$y2=$status";
$list_tgl="$list_tgl;$tgl";

}

}

if($keluary2=="0"){
$keluary2="1";
for($kk3=1; $kk3<=$d2; $kk3++){
$tgl="$kk3-$m2-$y2=$status";
$list_tgl="$list_tgl;$tgl";
}
}
}
}
}

$array_tgl=explode(";",$list_tgl);
$jml_array_tgl=count($array_tgl);

if($villa=="1" OR $villa=="2"){
$perday=20;
}elseif($villa=="3"){
$perday=50;
}elseif($villa=="4" OR $villa=="5"){
$perday=80;
}
$subtotal = $perday * ( $jml_array_tgl -1 );
echo("A$$subtotal");
}

?>

</font></div><br><br>

</td>

</tr>
</table>

</body>
</html>

3. File 'standard_room.php'

<style type="text/css">

<!--

.year {
font-family: Arial, Helvetica, sans-serif;
font-size:12px;
font-weight:bold;
color:#fff;
}

.month {
font-family:Arial, Helvetica, sans-serif;
font-size:11px;
font-weight:bold;
color:#1c5002;
background-color:#c8d793;
}


.date {
font-family:Arial, Helvetica, sans-serif;
font-size:10px;
font-weight:bold;
color:#1c5002;
}


.already {
font-family:Arial, Helvetica, sans-serif;
font-size:10px;
font-weight:bold;
color:#1c5002;
display:block;
background-color:#FF0000;
vertical-align:bottom;
}


.belom {
font-family:Arial, Helvetica, sans-serif;
font-size:10px;
font-weight:bold;
color:#1c5002;
height:6px;
widows:6px;
background-color:#FFFF00;
}


.table_cal{
border:solid 1px #00FF00;
}


.text1{
font-family:Arial, Helvetica, sans-serif;
font-size:12px;
color:#1c5002;
}


.table_resv{
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size:11px;
color:#637f00;
}


.txt_jdl {
font-family: Arial, Helvetica, sans-serif;
font-size:13px;
color:#637f00;
font-weight:bold;
}

.input{
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size:11px;
background-color:#dcee9a;
color:#637f00;
border:1px solid #b1da20;
}


.button{
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size:11px;
color:#fff;
background-color:#637f00;
border:1px solid #b1da20;
}


.bintang {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size:14px;
font-weight:bold;
color:#FF0000;
font-style:italic;
}



-->

</style>







<?php

$this_month=date("m");

$new_row=$this_month+2;

$sixmonthlater=$this_month + 6 ;

$this_year= date("Y");

$oneyearlater= $this_year + 1 ;



$sel_res=mysql_query("SELECT * FROM reservation WHERE type_villa='2' AND (y1='$this_year' OR y2='$this_year' OR y1='$oneyearlater' OR y2='$oneyearlater')

") or die(mysql_error());



$jml_res=mysql_num_rows($sel_res);



//echo("jumlah yang terecord: $jml_res");



$list_tgl="";

$status="";

for($r=0; $r<$jml_res; $r++){

$req_res=mysql_fetch_array($sel_res);

$d1=$req_res['d1'];

$m1=$req_res['m1'];

$y1=$req_res['y1'];

$d2=$req_res['d2'];

$m2=$req_res['m2'];

$y2=$req_res['y2'];

$status=$req_res['status'];



//--kemungkinan 1 bulan in = bulan out AND tahun in = tahun out ---> m1=m2 AND y1=y2

if($m1=="$m2" AND $y1="$y2"){



for($k=$d1; $k<$d2+1; $k++){

$kkk++;



$tgl="$k-$m1-$y1=$status";

//echo("$tgl<br>");

$list_tgl="$list_tgl;$tgl";

}



}

//--kemungkinan 2 bulan out > bulan in AND tahun in = tahun out ---> m2>m1 AND y1=y2



if($m2 > $m1 AND $y1=="$y2"){



$selisihbulan=$m2-$m1;

$keluar1="0";

$keluar3="0";



for($mm1=$m1; $mm1<$m2+1; $mm1++){

$jml_hari = date('t',mktime(0,0,0,$mm1,1,$y1)); // This is to calculate number of days in a month



if($keluar1=="0"){

$keluar1="1";

for($k2=$d1; $k2<$jml_hari+1; $k2++){

$tgl="$k2-$m1-$y1=$status";

$list_tgl="$list_tgl;$tgl";

}

}



if($selisihbulan > 1 AND $mm1<$m2 AND $mm1>$m1){

for($kkk2=1; $kkk2<$jml_hari+1; $kkk2++){

$tgl="$kkk2-$mm1-$y1=$status";

$list_tgl="$list_tgl;$tgl";

}

}



if($keluar3=="0"){

$keluar3="1";

for($kk2=1; $kk2<=$d2; $kk2++){

$tgl="$kk2-$m2-$y1=$status";

$list_tgl="$list_tgl;$tgl";

}

}

}



}



//----kemungkinan 3 : tahun out > tahun in ------- >

if($y2 > $y1){

$selisihtahun=$y2-$y1;

$selisihbulanthpertama=12-$m1;

$keluary1="0";

$keluary2="0";



for($yy1=$y1; $yy1<$y2+1; $yy1++){



for($mmm1=1; $mmm1<13; $mmm1++){

$jml_hari = date('t',mktime(0,0,0,$mmm1,1,$yy1)); // This is to calculate number of days in a month



if($keluary1=="0"){

$keluary1="1";

for($k3=$d1; $k3<$jml_hari+1; $k3++){

$tgl="$k3-$m1-$y1=$status";

$list_tgl="$list_tgl;$tgl";

}

}



if($selisihbulanthpertama > 1 AND $mmm1<13 AND $mmm1>$m1 AND $yy1=="$y1"){

for($kkk3=1; $kkk3<$jml_hari+1; $kkk3++){

$tgl="$kkk3-$mmm1-$y1=$status";

$list_tgl="$list_tgl;$tgl";

}

}





if($selisihtahun > 1 AND $yy1 > $y1 AND $yy1 < $y2){

for($kkkkk3=1; $kkkkk3<$jml_hari+1; $kkkkk3++){

$tgl="$kkkkk3-$mmm1-$yy1=$status";

$list_tgl="$list_tgl;$tgl";

}

}



if($m2 > 1 AND $mmm1<$m2 AND $mmm1>0 AND $yy1=="$y2"){

for($kkkk3=1; $kkkk3<$jml_hari+1; $kkkk3++){

$tgl="$kkkk3-$mmm1-$y2=$status";

$list_tgl="$list_tgl;$tgl";

}

}



if($keluary2=="0"){

$keluary2="1";

for($kk3=1; $kk3<=$d2; $kk3++){

$tgl="$kk3-$m2-$y2=$status";

$list_tgl="$list_tgl;$tgl";

}

}

}



}



}



}



$array_tgl=explode(";",$list_tgl);

$jml_array_tgl=count($array_tgl);



echo("

<table width='500' align='right'>

<tr><td width=350><span class='text1'>Booking Status - Single Rooms 2</span></td>

<td>

<table border=\"0\" cellpadding=\"1\" cellspacing=\"1\" width='300'>

<tr>

<td bgcolor=\"#ffff00\" height=\"4\" width=\"20\">&nbsp;&nbsp;</td>

<td class='date' width='140'><span class='text1'><strong>= reserved</strong></span></td>

<td bgcolor=\"#FF0000\" height=\"4\" width=\"20\">&nbsp;&nbsp;</td>

<td class='date'><span class='text1'><strong>= confirmed</strong></span></td>

</tr>

</table>

</td><tr></table><br><br>



");

echo("<table border='0' cellpadding='0' class='table_cale'>

<tr>"); ///---buat tabel 3 kolom 2 baris

for($prm = $this_month; $prm < $sixmonthlater; $prm++){



echo("<td valign='top'>");///---buat tabel 3 kolom 2 baris



if(isset($prm) and $prm > 0){

$m=$prm+$chm;

}else{

$m= date("m");}



$d= date("d"); // Finds today's date

$y= date("Y"); // Finds today's year



$no_of_days = date('t',mktime(0,0,0,$m,1,$y)); // This is to calculate number of days in a month



$mn=date('M',mktime(0,0,0,$m,1,$y)); // Month is calculated to display at the top of the calendar

$mn2=date('m',mktime(0,0,0,$m,1,$y)); // --



$yn=date('Y',mktime(0,0,0,$m,1,$y)); // Year is calculated to display at the top of the calendar



$j= date('w',mktime(0,0,0,$m,1,$y)); // This will calculate the week day of the first day of the month



for($k=1; $k<=$j; $k++){ // Adjustment of date starting

$adj .="<td>&nbsp;</td>";

}



/// Starting of top line showing name of the days of the week



echo "<table border='1' bordercolor='#FFFF00' cellspacing='0' cellpadding='0' align=center>



<tr><td>";



echo "

<table cellspacing='0' cellpadding='1' align=center width='100' border='0' class='table_cal'>

<td colspan=7 align=center bgcolor='#f7941d' class='year'>$mn $yn </td>

</tr><tr class='month'>";



echo "<td>Sun</td><td>Mon</td><td>Tue</td><td>Wed</td><td>Thu</td><td>Fri</td><td>Sat</td></tr><tr>";



////// End of the top line showing name of the days of the week//////////



//////// Starting of the days//////////

for($i=1;$i<=$no_of_days;$i++){

echo $adj."";



///--cek status kamar uda dipesan apa belom---



$ketemu="";

for($cek2=1; $cek2<$jml_array_tgl; $cek2++) {

$tgl_2=explode("-",$array_tgl[$cek2]);

$dd=$tgl_2[0];

$mm=$tgl_2[1];

$yy=$tgl_2[2];



$yy=explode("=",$yy);

if($yy[0]=="$yn" AND $mm=="$mn2" AND $dd=="$i"){

$cek2="$jml_array_tgl";

$ketemu="1";

$status=$yy[1];

}

}



if($ketemu=="1" AND $status=="1"){

echo("<td valign='middle' align='center' bgcolor='#ff0000'><span class='date'><font color='#ffffff'>");



}elseif($ketemu=="1" AND $status=="0"){

echo("<td valign='middle' align='center' bgcolor='#ffff00'><span class='date'>");

}else{

echo("<td valign='middle' align='center'><span class='date'>");

}



echo "

$i</span>

<br>"; // This will display the date inside the calendar cell

echo "</td>";

$adj='';

$j ++;

if($j==7){echo "</tr><tr>";

$j=0;}



}



echo "</tr></table></td></tr></table><br>";

echo("<td>");///---buat tabel 3 kolom 2 baris



//---new row ---

if($prm=="$new_row"){ echo("</tr><tr>"); }

////////////<br />



}

echo("</tr></table>"); ///---buat tabel 3 kolom 2 baris



?>



<br><br>

<p class="txt_jdl" align="right"><a name="reservation"></a>RESERVATION</p>

<form method="post" action="send_reservation.php" name="SampleForm">

<input type="hidden" name="env_report" value="REMOTE_HOST,REMOTE_ADDR,HTTP_USER_AGENT,AUTH_TYPE,REMOTE_USER">

<input type="hidden" name="recipients" value="info8YAuluwatugeckoinn.com" />

<input type="hidden" name="required" value="email:Your email address,realname:Your name" />

<input type="hidden" name="subject" value="Reservation posted from website" />

<input type="hidden" name="good_url" value="http://uluwatugeckoinn.com/thankyou.html" />

<table border="0" align="right" width="450" cellpadding="0" cellspacing="0" class="table_resv">

<tr>

<td width="180" height="30" align="left" valign="top">Name<span class="bintang">*</span></td>

<td width="10" valign="top">:</td>

<td width="1" valign="top"></td>

<td width="210" colspan="10" align="left" valign="top"><input name="realname" type="text" class="input" size="31" /></td>

</tr>

<tr>
<td height="30" align="left" valign="top">Address</td>
<td valign="top">:</td>
<td valign="top"></td>
<td colspan="10" align="left" valign="top"><input name="address" type="text" class="input" size="31" /></td>
</tr>
<tr>
<td height="30" align="left" valign="top">Telephone no.</td>
<td valign="top">:</td>
<td valign="top"></td>
<td colspan="10" align="left" valign="top"><input name="phone" type="text" class="input" size="31" /></td>
</tr>
<tr>
<td height="30" align="left" valign="top">E-mail <span class="bintang">*</span></td>
<td valign="top">:</td>
<td valign="top"></td>
<td colspan="10" align="left" valign="top"><input name="email" type="text" class="input" size="31" /></td>
</tr>
<tr>
<td height="30" align="left" valign="top">Type of villa</td>
<td valign="top">:</td>
<td valign="top"></td>
<td colspan="10" align="left" valign="top">
<select name="villa" class="input">
<?php
$sel_v=mysql_query("SELECT * FROM villa ORDER BY id_villa") or die(mysql_error());
$jml_v=mysql_num_rows($sel_v);
echo("jml_villa : $jml_v");
for($v=0; $v<$jml_v; $v++){
$req_v=mysql_fetch_array($sel_v);
$id_villa=$req_v['id_villa'];
$villa=$req_v['villa'];
echo("<option value='$id_villa'>$villa</option>");
}
?>
</select> </td>
</tr>
<tr>
<td height="30" align="left" valign="top">No. of guest</td>
<td valign="top">:</td>
<td valign="top"></td>
<td colspan="10" align="left" valign="top"><input name="guest" type="text" class="input" size="5" /></td>
</tr>
<tr>
<td height="30" align="left" valign="top">Checkin (Arrival date)</td>
<td valign="top">:</td>
<td valign="top"></td>
<td colspan="10" align="left" valign="top">
<select name="arr_date" size="1" class="input">
<option></option>
<option value="01">01</option>
<option value="02">02</option>
<option value="03">03</option>
<option value="04">04</option>
<option value="05">05</option>
<option value="06">06</option>
<option value="07">07</option>
<option value="08">08</option>
<option value="09">09</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
<option value="24">24</option>
<option value="25">25</option>
<option value="26">26</option>
<option value="27">27</option>
<option value="28">28</option>
<option value="29">29</option>
<option value="30">30</option>
<option value="31">31</option>
</select>
<select name="arr_month" size="1" class="input">
<option></option>
<option value="01">January</option>
<option value="02">February</option>
<option value="03">March</option>
<option value="04">April</option>
<option value="05">May</option>
<option value="06">June</option>
<option value="07">July</option>
<option value="08">August</option>
<option value="09">September</option>
<option value="10">October</option>
<option value="11">November</option>
<option value="12">December</option>
</select>
<select name="arr_year" size="1" class="input">
<option></option>
<option value="2008">2008</option>
<option value="2009">2009</option>
<option value="2010">2010</option>
</select> </td>
</tr>
<tr>
<td height="30" align="left" valign="top">Checkout (Departure date)</td>
<td valign="top">:</td>
<td valign="top"></td>
<td colspan="10" align="left" valign="top">
<select name="dep_date" size="1" class="input">
<option></option>
<option value="01">01</option>
<option value="02">02</option>
<option value="03">03</option>
<option value="04">04</option>
<option value="05">05</option>
<option value="06">06</option>
<option value="07">07</option>
<option value="08">08</option>
<option value="09">09</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
<option value="24">24</option>
<option value="25">25</option>
<option value="26">26</option>
<option value="27">27</option>
<option value="28">28</option>
<option value="29">29</option>
<option value="30">30</option>
<option value="31">31</option>
</select>
<select name="dep_month" size="1" class="input">
<option></option>
<option value="01">January</option>
<option value="02">February</option>
<option value="03">March</option>
<option value="04">April</option>
<option value="05">May</option>
<option value="06">June</option>
<option value="07">July</option>
<option value="08">August</option>
<option value="09">September</option>
<option value="10">October</option>
<option value="11">November</option>
<option value="12">December</option>
</select>
<select name="dep_year" size="1" class="input">
<option></option>
<option value="2008">2008</option>
<option value="2009">2009</option>
<option value="2010">2010</option>
<option value="2011">2011</option>
<option value="2012">2012</option>
</select> </td>
</tr>
<tr>
<td height="5" colspan="13" valign="top"></td>
</tr>
<tr>
<td align="left" valign="top">Special Request </td>
<td valign="top">:</td>
<td valign="top"></td>
<td colspan="10" align="left" valign="top"><textarea name="comments" cols="30" rows="5" class="input"></textarea></td>
</tr>
<tr>
<td height="10" colspan="13"></td>
</tr>
<tr>
<td></td>
<td></td>
<td height="24" colspan="11" align="center" valign="middle"><input type="submit" value="Reserve now" onClick="MM_validateForm('realname','','R','email','','Risemail');return document.MM_returnValue" class="button" /></td>
</tr>
</table>
</form>