<?
session_start();
require("auth.php");

//check date
$today = getdate();
$month = $today['mon']; 
$mday = $today['mday']; 
$year = $today['year'];

//$from_date = mktime(0, 0, 0, $month, $mday, $year);

//get details from registration table
$sql = "select * from REGISTERNEW";
$result = db_query($sql);

for ($x = 0; $x < db_numrows($result); $x++) {	
	$row = db_fetch_array($result,1);
	$id = $row["id"];
	$surname = $row["surname"]; 
	$first = $row["first"]; 
	$theday = $row["day_list"]; 
	$themonth = $row["month_list"]; 
	$theyear = $row["year"];
	$receipent = $row["email"];

	$birthday = $theday . $themonth;
	$presentbirthday = $mday . $month;

	if ($presentbirthday == $birthday) {
		$subject="Birthday wishes from the *chill*";
		$header="From: TheChillClub";
		$footer="\n\n*chill*,".
		"\nUnit 111, Block B,".
		"\nPhileo Damansara 2,".
		"\nOff Jalan Damansara,".
		"\n46350 Petaling Jaya".
		"\nTel. + 60.03.74919438 / 28".
		"\ninfo@thechillclub.com";
		$message="\n\nHappy Birthday, ". $first . "! We at *chill* wish you Peace, Love and Happiness on your Birthday and every day to last until your next.".
		"\n\nIf you’ve got nothing planned for Your Night, do drop by for a visit. We would love to be part of the celebration that marks another year for you.". $footer;
		
		mail($receipent,$subject,$message,$header);
	}
}
?>