Location: PHPKode > projects > Time Recording System > sendReminder.php
<?
require("header.php");
	function __autoload($class_name) {
		require_once $class_name . '.php';
	}
  
    if(!isset($_GET["refid"]) && !isset($_GET["refidList"]))
	{
		header("Location: index2.php?status=ciclamat");
		die(); 
		}

	$dbconn = new dbcontrol();
	$connectionStatus = $dbconn->connectdb();
	if(isset($_GET["refid"]))
	{
		$refid = intval($_GET["refid"]);
		$queryString="SELECT * FROM tbl_staff_lookup WHERE refid = ".$refid;
	}
	else
	{
		$refidArray = explode(",",htmlspecialchars($_GET["refidList"]));
		$queryString="SELECT * FROM tbl_staff_lookup WHERE refid IN (".implode(",",$refidArray).")";
	}
// 	echo $queryString;
// 	die();
	$failNumber = 0;
	$queryResult = $dbconn->sendquery2($queryString);
	$rowNr = pg_num_rows($queryResult);
	if($rowNr<1)
	{
		$status = "error0";
	}
	else
	{
		for($i=0;$i<$rowNr;++$i)
		{
			//sending an e-mail to the employee
			$rowarray = pg_fetch_array($queryResult,null,PGSQL_ASSOC);
		   	$subject = "Time sheet reminder";
			$message = "Dear ".ucwords(stripslashes($rowarray["fname"]." ".$rowarray["lname"])).",\n\n";
			$message.= "This is an automated reminder for you to fill in your timesheet. Please login at http://timesheets.thehumanjourney.net and submit it as soon as possible..\n\n";
			$message.= "Thank you \n\nAdmin";
			$patern = "^([a-z0-9])(([\\-]|[\.]|[_]+)?([a-z0-9]+))*(@)([a-z0-9])((([-]+)?([a-z0-9]+))?)*((.[a-z]{2,3})?(.[a-z]{2,6}))$";
			
			if(eregi($patern,$rowarray["email"])===FALSE)
			{
				++$failNumber;
// 				echo strtoupper($rowarray["email"]);
				continue;
			}
			if(!mail(stripslashes($rowarray["email"]),$subject,$message,"From: hide@address.com"))
				++$failNumber;
		}
		if($failNumber>0)
			$status = $failNumber;
		else
			$status = "sent";
	}
	header("Location: submissionStatus.php?status=".$status);
	die();
?>
Return current item: Time Recording System