PHP Form >:(

First I am not a developer. I am just trying to reverse engineer the existing php form.

This is the test page that I have setup.
http://www.absenteehomeowners.com/arrival/index-test.php

Currently the form emails the form information to a specific email address. I am trying to add the function of where if the user provides an email address then the information is also sent to the user.

Here are the pages that I think are involved.

index-test.php
[php]<?php

--------------------------------------------------------------

--------------------------------------------------------------

switch ($_SERVER[‘HTTP_HOST’]) {
case ‘www.absenteehomeowners.com’:
case ‘absenteehomeowners.com’:
default:
include_once($_SERVER[‘DOCUMENT_ROOT’] . ‘/etc/absenteehomeowners.php’);
break;
case ‘absenteehomeowners.stoutstreet.com’:
include_once($_SERVER[‘DOCUMENT_ROOT’] . ‘/dev/absenteehomeowners/etc/absenteehomeowners.php’);
break;
}
page_open(’’);
$dbg = new debug (SITE_PATH . ‘/debug/admin_index.txt’,DEBUG_FROM,DEBUG_TO);
$dbg->set_show (“File”);

$template = ‘arrival/index-test.tpl’;
$arrivalon=“id=‘on’”;
$navfix=‘550’;

$notification=new Notification();

SiteCookie::extract(“absenteehomeowners_arrival”);
if ((isset($_COOKIE[‘last_name’])) && ($_COOKIE[‘last_name’] != ‘’)) {
$last_name = $_COOKIE[‘last_name’];
}
if ((isset($_COOKIE[‘address’])) && ($_COOKIE[‘address’] != ‘’)) {
$address = $_COOKIE[‘address’];
}
if ((isset($_COOKIE[‘housekeeping’])) && ($_COOKIE[‘housekeeping’] != ‘’)) {
switch ($_COOKIE[‘housekeeping’]) {
case ‘no’:
default:
$tpl->set_var(‘no_select’, ‘checked’);
break;
case ‘prior’:
$tpl->set_var(‘prior_select’, ‘checked’);
break;
case ‘after’:
$tpl->set_var(‘after_select’, ‘checked’);
break;
case ‘both’:
$tpl->set_var(‘both_select’, ‘checked’);
break;
}
}
if ((isset($_COOKIE[‘special’])) && ($_COOKIE[‘special’] != ‘’)) {
$tellus = $_COOKIE[‘special’];
}

//begin form submit
while ( is_array($HTTP_POST_VARS) && list($key, $val) = each($HTTP_POST_VARS)) {
$send_mail = true;
$spam_score = 0;
$reason = ‘’;
switch ($key) {
case “notification_submit”:
$notification->handlePostVars();
$validator=new Validator();
$last_name = $validator->strip_metas($_POST[‘last_name’]);
$email_address = $validator->strip_metas($_POST[‘email_address’]);
$address = $validator->strip_metas($_POST[‘address’]);
$arrival = $_POST[‘arrival’];
$departure = $_POST[‘departure’];
$housekeeping = $_POST[‘housekeeping’];
$tellus = $validator->strip_metas($_POST[‘tellus’]);
$remember = $_POST[‘remember’];
$notification->setIPAddress($_SERVER[‘REMOTE_ADDR’]);
if (! ($last_name) || ($last_name == ‘’)) {
$error_msg .= ’
- Missing last name.’;
$last_name_req = ‘notification_req_failed’;
}
if ( (! ($address)) || ($address == ‘’)) {
$error_msg .= ’
- Missing address.’;
$address_req = ‘notification_req_failed’;
}
if ( (! ($housekeeping)) || ($housekeeping == ‘’)) {
$error_msg .= ’
- Missing housekeeping selection.’;
$housekeeping_req = ‘notification_req_failed’;
}
if ( (! ($arrival)) || ($arrival == ‘’)) {
$error_msg .= ’
- Missing arrival date.’;
$arrival_req = ‘notification_req_failed’;
}
else {
if((substr_count($arrival,DATE_SEPARATOR))<>2){
$error_msg .= ’
- Invalid arrival date – please use ’ . DATE_SEPARATOR;
$arrival_req = ‘notification_req_failed’;
} elseif (!preg_match(’/^\d{1,2}/\d{1,2}/\d{4}$/’, $arrival)) {
$error_msg .= ’
- Invalid arrival date – please use ’ . DATE_FORMAT;
$arrival_req = ‘notification_req_failed’;
} else {
$arr=split(DATE_SEPARATOR,$arrival); // splitting the array
$mm=$arr[0]; // first element of the array is month
$mmresult=ereg("^[0-9]+$",$mm,$trashed);
if (!($mmresult)) {
$error_msg .= ’
- Invalid arrival month.’;
$arrival_req = ‘notification_req_failed’;
}
$dd=$arr[1]; // second element is date
$ddresult=ereg("^[0-9]+$",$dd,$trashed);
if (!($ddresult)) {
$error_msg .= ’
- Invalid arrival day.’;
$arrival_req = ‘notification_req_failed’;
}
$yy=$arr[2]; // third element is year
$yyresult=ereg("^[0-9]+$",$yy,$trashed);
if (!($yyresult)) {
$error_msg .= ’
- Invalid arrival year.’;
$arrival_req = ‘notification_req_failed’;
}
If(!checkdate($mm,$dd,$yy)){
$error_msg .= ’
- Invalid arrival date.’;
$arrival_req = ‘notification_req_failed’;
} else {
$checkdate = dateDiff(DATE_SEPARATOR,$arrival,CURRENT_DATE);
//echo intval($checkdate);
If ( (intval($checkdate) < intval(CURRENT_DAY_SOONEST)) ) {
$error_msg .= ’
- Arrival date must be at least ’ . CURRENT_DAY_SOONEST. ’ days from today. ‘;//You have a difference of ’ . $checkdate;
//$error_msg .= ’
- Arrival date must be no more than’ . CURRENT_DAY_SOONEST. ’ days from today. checkdate date_diff(’ .$arrival .’,’. CURRENT_DATE. ‘) ’ . $checkdate;
$arrival_req = ‘notification_req_failed’;
}
If ($checkdate > CURRENT_DAY_LATEST) {
$error_msg .= ’
- Arrival date must be no more than ’ . CURRENT_DAY_LATEST. ’ days from today. ‘;//You have a difference of ’ . $checkdate;
//$error_msg .= ’
- Arrival date must be no more than ’ . CURRENT_DAY_LATEST. ’ days from today. checkdate date_diff(’ .$arrival .’,’. CURRENT_DATE. ‘) ’ . $checkdate;
$arrival_req = ‘notification_req_failed’;
}
}
}
}
if ( (! ($departure)) || ($departure == ‘’)) {
$error_msg .= ’
- Missing departure date.’;
$departure_req = ‘notification_req_failed’;
}
else {
if((substr_count($departure,DATE_SEPARATOR))<>2){
$error_msg .= ’
- Invalid departure date – please use ’ . DATE_SEPARATOR;
$departure_req = ‘notification_req_failed’;
} elseif (!preg_match(’/^\d{1,2}/\d{1,2}/\d{4}$/’, $departure)) {
$error_msg .= ’
- Invalid departure date – please use ’ . DATE_FORMAT;
$arrival_req = ‘notification_req_failed’;
} else {
$arr=split(DATE_SEPARATOR,$departure); // splitting the array
$mm=$arr[0]; // first element of the array is month
$mmresult=ereg("^[0-9]+$",$mm,$trashed);
if (!($mmresult)) {
$error_msg .= ’
- Invalid departure month.’;
$departure_req = ‘notification_req_failed’;
}
$dd=$arr[1]; // second element is date
$ddresult=ereg("^[0-9]+$",$dd,$trashed);
if (!($ddresult)) {
$error_msg .= ’
- Invalid departure day.’;
$departure_req = ‘notification_req_failed’;
}
$yy=$arr[2]; // third element is year
$yyresult=ereg("^[0-9]+$",$yy,$trashed);
if (!($yyresult)) {
$error_msg .= ’
- Invalid departure year.’;
$departure_req = ‘notification_req_failed’;
}
If(!checkdate($mm,$dd,$yy)){
$error_msg .= ’
- Invalid departure date.’;
$departure_req = ‘notification_req_failed’;
} else {
$checkdate = dateDiff(DATE_SEPARATOR,$departure,$arrival);
If ($checkdate < 0) {
$error_msg .= ’
- Departure date must be later than arrival date. ‘;//checkdate date_diff(’ .$departure .’,’. $arrival. ‘) ’ . $checkdate;
//$error_msg .= ’
- Departure date must be later than arrival date. checkdate date_diff(’ .$departure .’,’. $arrival. ‘) ’ . $checkdate;
$departure_req = ‘notification_req_failed’;
} else {
If ($checkdate > DEPARTURE_LATEST) {
$error_msg .= ’
- Departure date must be no more than ’ . DEPARTURE_LATEST. ’ days from arrival. ‘;//You have a difference of ’ . $checkdate;
//$error_msg .= ’
- Departure date must be no more than ’ . DEPARTURE_LATEST. ’ days from departure. checkdate date_diff(’ .$departure .’,’. CURRENT_DATE. ') ’ . $checkdate;
$departure_req = ‘notification_req_failed’;
}
}
}
}
}

		if (isset ($error_msg)) {
			$display_error_msg = '<p id="error">There was an error submitting your form. ';
			$display_error_msg .= 'Please correct the errors below and resubmit.<span id="errormsg">' . $error_msg . '</span></p>';
			break;
		}

		if (isset($remember) && ($remember == 'y')) {
			// Create a local object
			$SiteCookie=new SiteCookie("absenteehomeowners_arrival");

			// Add the variables to be saved in the cookie

			$SiteCookie->put("last_name",$last_name);
			$SiteCookie->put("address",$address);
			$SiteCookie->put("housekeeping",$housekeeping);
			$SiteCookie->put("special",$tellus);
			$SiteCookie->put("email_address",$email_address);
			$SiteCookie->put("time",time());

			// Set the cookie
			$SiteCookie->set();
		} else {
			$SiteCookie=new SiteCookie("absenteehomeowners_arrival", time()-86400);
			// Clear all values
			$SiteCookie->clear();

				// Set the cookie
			$SiteCookie->set();
		}

		if ($send_mail == true && ($spam_score < 2)) { //
			$notification_ret_val = $notification->sendInfo($spam_score,$reason);
			if (!$notification_ret_val || ($notification->getErrorMessage())) {
				$error_msg .= $notification->getErrorMessage();
				$dbg->report ("\n\n notification->getErrorMessage: ", __LINE__, __FILE__, "", $notification->getErrorMessage());
				$subject .= ' sendInfo() ERROR';
				$body = $error_msg . "\nView the debug log here:\n";
				$body = '<a href="http://' .$GLOBALS[HTTP_HOST] . '/debug/notification.php.txt">http://' . $GLOBALS[HTTP_HOST] . '/debug/notification.php.txt</a>';
				$debug_ret_val=mail(SUBMIT_TO,$subject,$body,HEADERS);
				break;
			} else {
				//echo 'WILL SEND spam_score=' . $spam_score;
				//echo '<br />reason = ' . $reason;
				$page='thanks';
			}
		} else {
			//echo 'WILL <strong>NOT</strong> SEND spam_score=' . $spam_score;
			//echo '<br />reason = ' . $reason;
			$page='thanks';
		}
		break;
	default:
		break;
}

} //end form submit

$tpl->set_var(‘last_name’, $last_name);
$tpl->set_var(‘email_address’, $email_address);
$tpl->set_var(‘address’, $address);
$tpl->set_var(‘arrival’, $arrival);
$tpl->set_var(‘departure’, $departure);
$tpl->set_var(‘housekeeping’, $housekeeping);
$tpl->set_var(‘tellus’, $tellus);

$tpl->set_var(‘last_name_req’, $last_name_req);
$tpl->set_var(‘email_address’, $email_address);
$tpl->set_var(‘address_req’, $address_req);
$tpl->set_var(‘arrival_req’, $arrival_req);
$tpl->set_var(‘departure_req’, $departure_req);
$tpl->set_var(‘housekeeping_req’, $housekeeping_req);

if (isset($_POST[‘housekeeping’])) {
$housekeeping = $_POST[‘housekeeping’];
switch ($housekeeping) {
case ‘no’:
default:
$tpl->set_var(‘no_select’, ‘checked’);
break;
case ‘prior’:
$tpl->set_var(‘prior_select’, ‘checked’);
break;
case ‘after’:
$tpl->set_var(‘after_select’, ‘checked’);
break;
case ‘both’:
$tpl->set_var(‘both_select’, ‘checked’);
break;
}
}

if (isset($page)) {
switch ($page) {
case ‘thanks’:
default:
header(“Location: thanks.php”);
break;
}
}

if (isset ($error_msg)) {
$tpl->set_var(ERROR_MSG, $display_error_msg);
}

set_header($header_template);
set_nav($nav_template);
set_body(SITE_NAME . ‘.tpl’,$template,SITE_TITLE);
set_footer($footer_template);

$tpl->set_var(‘arrivalon’, $arrivalon);
$tpl->set_var(‘navfix’, $navfix);

$tpl->parse(‘HEADER’, ‘header’);
$tpl->parse(‘NAV’, ‘nav’);
$tpl->parse(‘BODY’, ‘body’);
$tpl->parse(‘FOOTER’, ‘footer’);
$tpl->parse(‘MAIN’, ‘wrapper’);
$tpl->p(‘MAIN’);
page_close();
?>[/php]

index-test.tpl

<div id="page">
  <h1>Arrival Notification &amp; Scheduling</h1>
  <p>To schedule your arrival and departure dates please fill out the information below. All on-line
    notifications must be made at least 3 days prior to your arrival; however, if you require housekeeping prior to your arrival a minimum of 7 days advance notice is required. <img src="/images/art/arrival.jpg" width="170" height="112" alt="" title="" align="left" class="art" /> If that deadline has already
    passed, please call us at 760/934-6563 or 800/522-3255 to
    schedule your arrival and departure dates.</p>
  <p><em><strong>Please Note:</strong> Absentee Homeowners Service is not a rental
    agency. The form below is for the exclusive use of our clients.</em></p>
  <p><em>(All fields below are required.)</em></p>
  {ERROR_MSG}
  <form method="post" action="index.php" name="arrival">
    <div class="row"> <span class="{last_name_req}">Last Name</span><span class= "formw">
      <input type="text" name="last_name" value="{last_name}" size="45" maxlength="44" />
      </span> </div>
    <div class="row"> <span class="{address_req}">House Address</span><span class= "formw">
      <input type="text" name="address" value="{address}" size="45" maxlength="44" />
      </span> </div>
    <div class="row"> <span class="{arrival_req}">Arrival Date</span><span class= "formw">
      <input type="text" name="arrival" value="{arrival}" size="11" maxlength="10" />
      <em>(format: {DATE_FORMAT})</em></span> </div>
    <div class="row"> <span class="{departure_req}">Departure Date</span><span class= "formw">
      <input type="text" name="departure" value="{departure}" size="11" maxlength="10" />
      <em>(format: {DATE_FORMAT})</em></span> </div>
    <div class="explainrow">If there is a housekeeping scheduling conflict due to high volume or short turn around time we will contact you.</div>
    <div class="row"> <span class="{housekeeping_req}">Housekeeping</span>
      <div class="rowshort">
        <input type="radio" name="housekeeping" value="no" {no_select} />
        <label>No, thanks</label>
      </div>
      <div class="rowshort">
        <input type="radio" name="housekeeping" value="prior" {prior_select} />
        <label>Prior to Arrival</label>
      </div>
      <div class="rowshort">
        <input type="radio" name="housekeeping" value="after" {after_select} />
        <label>After Departure</label>
      </div>
      <div class="rowlong">
        <input type="radio" name="housekeeping" value="both" {both_select} />
        <label>Prior to Arrival  AND  After Departure</label>
      </div>
    </div>
    <div class="spacer">&nbsp;</div>
    <div class="row"> <span class="biglabel">Special Instructions</span><span class= "formw">
      <textarea name="tellus" cols="100" rows="4" >{tellus}</textarea>
      </span>
      <div class="spacer">&nbsp;</div>
      <div class="row">If you would like to receive an eMail confirmations of your submition please enter your eMail address below.<em> (optional)</em>,</br>
        <span class="{email_address}">eMail Address </span><span class= "formw">
        <input type="text" name="email_address" value="{email_address}" size="45" maxlength="44" />
        </span> </div>
      <div class="spacer">&nbsp;</div>
    </div>
    <div class="spacer">&nbsp;</div>
    <div class="spacer">&nbsp;</div>
    <div class="rowlong">
      <input type="checkbox" name="remember" id="remember" value="y" checked="checked" />
      <label for="remember">Remember my info</label>
    </div>
    <div id="submit">
      <input type="submit" value="Submit" name="notification_submit" id="notification_submit" />
    </div>
  </form>
  <script language="JavaScript" type="text/javascript">
		var validateDates;
		$(function () {
			var currDate = new Date(),
				currDay = new Date(currDate.getFullYear(), currDate.getMonth(), currDate.getDate());
			validateDates = function () {
				var priorArrDate = new Date(currDate.getFullYear(), currDate.getMonth(), currDate.getDate() + 7),
					arrDate = $('input[name=arrival]').val(),
					depDate = $('input[name=departure]').val(),
					failPriorCheck = false;
				$('.exception').remove();
				if (arrDate && new Date(arrDate) < priorArrDate) {
					failPriorCheck = true;
					$('input[name=housekeeping][value=prior],input[name=housekeeping][value=both]').each(function () {
						$(this).attr('disabled', true)
							.attr('checked', false)
							.siblings('label').css({
								color:'darkred',
								fontStyle:'italic'
							});
					});
				} else {
					$('input[name=housekeeping][value=prior],input[name=housekeeping][value=both]')
						.attr('disabled', false)
						.siblings('label').css({
							color:'#fff',
							fontStyle:'normal'
						});
				}
				if (depDate && new Date(depDate) < priorArrDate) {
					failPriorCheck = true;
					$('input[name=housekeeping][value=after]').each(function () {
						$(this).attr('disabled', true)
							.attr('checked', false)
							.siblings('label').css({
								color:'darkred',
								fontStyle:'italic'
							});
					});
				} else {
					$('input[name=housekeeping][value=after]')
						.attr('disabled', false)
						.siblings('label').css({
							color:'#fff',
							fontStyle:'normal'
						});
				}
				if (failPriorCheck) {
					$('.explainrow').before('<div class="explainrow exception" style="padding-bottom:0; color:darkred; font-style:italic;">\
						Seven days advance notice is required for housekeeping requests via the website. \
						Please call the office to confirm availability if you cannot give seven days advance notice. \
					</div>');
				}
			}
			$('input[name=arrival]').datepicker({
				onSelect: function (dateText) {
					// clear departure by default
					$('input[name=departure]').val('');
					// reset the minDate on the departure
					$('input[name=departure]').datepicker('option', 'minDate', new Date(dateText));
					// toggle disable on 'prior to departure' housecleaning selection
					validateDates();
				},
				// only allow dates in future
				beforeShowDay: function (date) {
					if (date >= currDay)
						return [true];
					else
						return [false];
				}
			});
			$('input[name=departure]').datepicker({
				onSelect: function (dateText) {
					// toggle disable on 'after departure' housecleaning selection
					validateDates();
				},
				// only allow dates past arrival date
				beforeShowDay: function (date) {
					var arrival = $('input[name=arrival]').val();
					if (date >= (arrival ? new Date(arrival) : currDay))
						return [true];
					else
						return [false];
				}
			});
			validateDates();
		});
		// Activate the appropriate input form field.
		document.arrival.last_name.focus();
	</script> 
</div>

absenteehoweowners.php
[php]<?php

---------------------------------------------------------------

ripped from phpop, among other places

---------------------------------------------------------------

the following files are required for the correct

operation of PHPLIB and encorpsecure utilities

define (‘SITE_NAME’, ‘absenteehomeowners’); // the application name
define (‘SITE_FOLDER’, SITE_NAME . ‘/’); // the folder for includes

switch ($_SERVER[‘HTTP_HOST’]) {
case ‘www.absenteehomeowners.com’:
case ‘absenteehomeowners.com’:
default:
define (‘SITE_PATH’, ‘/home/absentee/public_html’);
define (‘TEMPLATE_PATH’, ‘/home/absentee/public_html/templates/public/’);
define (‘STYLE_PATH’, ‘/lib/styles/’);
$base_url = ‘http://www.absenteehomeowners.com’;
define (‘DEBUG’, false);
define (‘SUBMIT_TO’, ‘[email protected], [email protected], [email protected]’);
break;
case ‘absenteehomeowners.stoutstreet.com’:
define (‘SITE_PATH’, ‘/var/www/html/dev/absenteehomeowners’); // the site folder path
define (‘TEMPLATE_PATH’, ‘/var/www/html/dev/absenteehomeowners/templates/public/’);
define (‘STYLE_PATH’, ‘/lib/styles/’);
$base_url = ‘http://absenteehomeowners.stoutstreet.com’;
define (‘DEBUG’, true);
define (‘SUBMIT_TO’, ‘[email protected], [email protected]’);
break;
}
include_once(SITE_PATH . ‘/etc/’ . SITE_FOLDER . SITE_NAME . ‘_define.php’); // required, contains constant definitions.
include_once(SITE_PATH . ‘/etc/’ . SITE_FOLDER . SITE_NAME . ‘_loader.php’); // required, contains site class files.
include_once(SITE_PATH . ‘/etc/’ . SITE_FOLDER . SITE_NAME . ‘_local.php’); // required, contains your local class instantiations.

$tpl->set_var(‘last_name_req’, $last_name_req);
$tpl->set_var(‘email_address’, $email_address);
$tpl->set_var(‘address_req’, $address_req);
$tpl->set_var(‘arrival_req’, $arrival_req);
$tpl->set_var(‘departure_req’, $departure_req);
$tpl->set_var(‘housekeeping_req’, $housekeeping_req);

$tpl->set_var(‘BASE_URL’, $base_url);
$tpl->set_var(‘CSS’, STYLE_PATH . SITE_NAME . ‘.css’);
$tpl->set_var(‘IE_CSS’, STYLE_PATH . SITE_NAME . ‘_ie.css’);
$tpl->set_var(‘IE6_CSS’, STYLE_PATH . SITE_NAME . ‘_ie6.css’);
$tpl->set_var(‘IE7_CSS’, STYLE_PATH . SITE_NAME . ‘_ie7.css’);

$tpl->set_var(‘SITE_TITLE’, SITE_TITLE);
$tpl->set_var(‘CURRENT_MONTH’, CURRENT_MONTH);
$tpl->set_var(‘CURRENT_DAY’, CURRENT_DAY);
$tpl->set_var(‘CURRENT_YEAR’, CURRENT_YEAR);
$tpl->set_var(‘DATE_FORMAT’, DATE_FORMAT);
?>
[/php]

notification.php
[php]<?php
//
// swiped from sourceforge 2.5 code
// Copyright 1999-2000 © The SourceForge Crew
// from User object by Tim Perdue, October 11, 2000
/*
Sets up database results and preferences for a notification and abstracts this info

GENERALLY YOU SHOULD NEVER INSTANTIATE THIS OBJECT DIRECTLY
USE notification_get_object() to instantiate properly - this will pool the objects
and increase efficiency

*/

/**
*

  • You can now optionally pass in a db result
  • handle. If you do, it re-uses that query
  • to instantiate the objects
  • IMPORTANT! That db result must contain all fields
  • from TBL_NOTIFICATION table or you will have problems

*/
$NOTIFICATION_OBJ=array();

/**
*

  • notification_get_object is useful so you can pool notification objects/save database queries
  • You should always use this instead of instantiating the object directly
  • @param notification_id required
  • @param res result set handle (“SELECT * FROM TBL_NOTIFICATION WHERE notification_id=xx”)
  • @returns a notification object or false on failure

*/

function &notification_get_object($notification_id,$res=false) {
//create a common set of group objects
//saves a little wear on the database

//automatically checks group_type and
//returns appropriate object

global $NOTIFICATION_OBJ;
if (!isset($NOTIFICATION_OBJ["_".$notification_id."_"])) {
	if ($res) {
		//the db result handle was passed in
	} else {
		$res=mysql_query("SELECT * FROM " . TBL_NOTIFICATION . " WHERE notification_id='$notification_id'");
	}
	if (!$res || mysql_numrows($res) < 1) {
		$NOTIFICATION_OBJ["_".$notification_id."_"]=false;
	} else {
		$NOTIFICATION_OBJ["_".$notification_id."_"]= new NOTIFICATION($notification_id,$res);
	}
}
return $NOTIFICATION_OBJ["_".$notification_id."_"];

}

class Notification extends Error {
var $classname = ‘Notification’;

//associative array of data from db
var $data_array;

var $notification_id;

var $email_Customer		= 'False';

//database result set handle
var $db_result;

var $form_names = array( 'last_name'											=> 'last_name',
						 'email_address'								=> 'email_address',
						 'housekeeping'								=> 'housekeeping',
						 'address'													=> 'address',
						 'arrival'														=> 'arrival',
						 'departure'											=> 'departure',
						 'tellus'															=> 'tellus',
						 'ip_address'										=> 'ip_address'
);

/**
 *	Notification($id,$res) - CONSTRUCTOR - GENERALLY DON'T USE THIS
 *
 *	instead use the notification_get_object() function call
 *	@param $id required - notification_id
 *	@param $res optional - database result set
 */
function Notification($notification_id=false,$res=false) {
	$this->Error();
	if ($notification_id) {
		$this->notification_id=$notification_id;
		if (!$res) {
			$this->db_result=mysql_query("SELECT * FROM " . TBL_NOTIFICATION . " WHERE notification_id='$notification_id'");
		} else {
			$this->db_result=$res;
		}
		if (mysql_numrows($this->db_result) < 1) {
			//function in class we extended
			$this->setError('Notification Not Found');
			$this->data_array=array();
		} else {
			//set up an associative array for use by other functions
			mysql_data_seek($this->db_result,0);
			$this->data_array=mysql_fetch_array($this->db_result);
		}
		$this->notification_id=$this->data_array['notification_id'];
	} else {
		$this->data_array=array();
	}
}
/**
*	changeFormNames
*	Used to change the select boxes name attribute.  You need to set this
*	_BEFORE_ using them.  Simply call this method, include the type of
*	element you are changing (years, months, days) and then include the
*	new name of the element.
*
*	@anotification 	public
*	@param	string	type	The name of the type: years, months, days
*	@param	string	value	The new name of the given type.
*	@return bool	True on success, False on failure.
*/
function changeFormNames ( $type, $value ) {
   $this->form_names[ $type ] = $value;
}

/**
 *	getData() - Return database result handle for direct access
 *
 *	Generally should NOT be used - here for supporting deprecated group.php
 *	@returns database result set handle
 */
function getData() {
	mysql_data_seek($this->db_result);
	return $this->db_result;
}

/**
 *	refreshNotificationData() - May need to refresh database fields
 *
 *	if an update occurred and you need to access the updated info
 */
function refreshNotificationData() {
	$this->db_result=mysql_query("SELECT * FROM " . TBL_NOTIFICATION . " WHERE notification_id='". $this->getNotificationId() ."'");
	$this->data_array=mysql_fetch_array($this->db_result);
}

/**
 *	getNotificationId() - Simply return the notification_id for this object
 *
 *	@returns this notification's notification_id number
 */
function getNotificationId() {
	return $this->notification_id;
}

/**
 *	setNotificationId()
 *
 *	@sets volunteer's notification_id
 */
function setNotificationId($notification_id) {
	$this->data_array['notification_id']=$notification_id;
}

/**
 *	getLastName()
 *
 *	@returns this notification's last_name
 */
function getLastName() {
	return $this->data_array['last_name'];
}

/**
 *	setLastName()
 *
 *	@sets notification's last_name
 */
function setLastName($last_name) {
	$this->data_array['last_name']=$last_name;
}

/**
 *	geteMailAddress()
 *
 *	@returns this notification's email_address
 */
function geteMailAddress() {
	return $this->data_array['email_address'];
}

/**
 *	seteMailAddress()
 *
 *	@sets notification's email_address
 */
function seteMailAddress($email_address) {
	$this->data_array['email_address']=$email_address;
}

/**
 *	getHousekeeping() - housekeeping
 *
 */
function getHousekeeping() {
	return $this->data_array['housekeeping'];
}

/**
 *	setHousekeeping() - housekeeping
 *
 */
function setHousekeeping($housekeeping) {
	$this->data_array['housekeeping']=$housekeeping;
}

/**
 *	getAddress() - address
 *
 */
function getAddress() {
	return $this->data_array['address'];
}

/**
 *	setAddress() - address
 *
 */
function setAddress($address) {
	$this->data_array['address']=$address;
}

	/**
 *	getArrival()
 *
 * 	@returns this notification's arrival
 */
function getArrival() {
	return $this->data_array['arrival'];
}

/**
 *	setArrival()
 *
 * 	@sets this notification's arrival
 */
function setArrival($arrival) {
	$this->data_array['arrival'] = $arrival;
}

	/**
 *	getDeparture()
 *
 * 	@returns this notification's departure
 */
function getDeparture() {
	return $this->data_array['departure'];
}

/**
 *	setDeparture()
 *
 * 	@sets this notification's departure
 */
function setDeparture($departure) {
	$this->data_array['departure'] = $departure;
}

/**
 *	getTellUs()
 *
 *	@returns this tellus
 */
function getTellUs() {
	return $this->data_array['tellus'];
}

/**
 *	setTellUs()
 *
 *	@sets tellus
 */
function setTellUs($tellus) {
	$this->data_array['tellus']=$tellus;
}

/**
 *	getIPAddress()
 *
 *	@returns this ip_address
 */
function getIPAddress() {
	return $this->data_array['ip_address'];
}

/**
 *	setIPAddress()
 *
 *	@sets ip_address
 */
function setIPAddress($ip_address) {
	$this->data_array['ip_address']=$ip_address;
}

/**
 *	handlePostVars()
 *
 *	@handles POSTed values
 */

function handlePostVars () {
global $HTTP_POST_VARS;

	foreach ( $this->form_names as $name => $form_name ) {
		if ( ( isset($HTTP_POST_VARS[ $form_name ]) ) && !empty($HTTP_POST_VARS[ $form_name ]) ) {
				$this->data_array[$name] = $HTTP_POST_VARS[ $form_name ];
		}
	}

}

/**
 *	sendInfo()
 *
 *	@sends the info
 */
function sendInfo($spam_score = '',$reason = '') {
	$subject = 'New notification from the ' . SITE_TITLE . ' website';
	$submit_body .= 'Last Name:  ' . " " . $this->data_array['last_name'];
	$submit_body .= "\n\n";
	$submit_body .= 'House Address:  ' . " " . $this->data_array['address'];
	$submit_body .= "\n\n";
	$submit_body .= 'Arrival Date:  ' . " " . $this->data_array['arrival'];
	$submit_body .= "\n\n";
	$submit_body .= 'Departure Date:  ' . " " . $this->data_array['departure'];
	$submit_body .= "\n\n";
	$submit_body .= 'Housekeeping:  ' . " " . $this->data_array['housekeeping'];
	$submit_body .= "\n\n";
	$submit_body .= 'Special Instructions:  ' . " " .  nl2br($this->data_array['tellus']);
	$submit_body .= "\n\n";
	$submit_body .= 'eMail Address:  ' . " " . $this->data_array['email_address'];
	$submit_body .= "\n\n\n-----------\n";
	$submit_body .= 'If there is a housekeeping scheduling conflict due to high volume or short turn around time we will contact you.';
	$submit_body .= "\n";
	$submit_body .= 'Jeff & Drea Perry (Owners)';
	$submit_body .= "\n\n";
	$submit_body .= 'Toll Free: (800) 522-3255';
	$submit_body .= "\n";
	$submit_body .= 'Phone: (760) 934-6563';
	$submit_body .= "\n\n";
	$submit_body .= 'P.O. Box 1161';
	$submit_body .= "\n";
	$submit_body .= 'Mammoth Lakes, CA 93546';
	$submit_body .= "\n-----------\n\n\n";
	$submit_body .= 'IP Address:  ' . $this->data_array['ip_address'];
	$submit_body .= "\n";

	$submit_ret_val=mail(SUBMIT_TO,$subject,$submit_body,HEADERS);
		//$debug_subject =SITE_TITLE . ' Notification Debug: IP address ' . $REMOTE_ADDR . ' : _score=' . $spam_score;
		//$submit_ret_val=mail(DEBUG_TO,$debug_subject,$submit_body,HEADERS);
	if ($submit_ret_val !=1) {
		$this->setError("ERROR - Could Not Send Notification\n");
		return false;
	} else {
		//$debug_subject = SITE_TITLE .' Notification Debug: IP address ' . $this->data_array['ip_address'];
		//$submit_ret_val=mail(DEBUG_TO,$debug_subject,$submit_body,HEADERS);
		return true;
	}
}

/**
 *	getError()
 *
 * 	@returns any errors
 */
function getError() {
	return $this->Error;
}

}
?>[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service