Your IP : 216.73.217.79


Current Path : /var/www/cesa.co.za/php/
Upload File :
Current File : /var/www/cesa.co.za/php/ypfjoinmatches.php

<?php
$pagetitle = "Join the YPF";

include($_SERVER['DOCUMENT_ROOT'] . "/php/inc_db.php");

?>
<img src="https://www.cesa.co.za/sites/default/files/CESA%20YPF_Logo_small.jpg" alt="YPF" hspace="10" align="left" />
<?php
if ($_POST["selContact"] == "NONE") {
	// If there was no match to existing data, add this as a new contact
	$sDOB = "NULL";
	if (!empty($_POST["DOBDay"]) && !empty($_POST["DOBMonth"]) && !empty($_POST["DOBYear"]) && is_numeric($_POST["DOBDay"]) && is_numeric($_POST["DOBYear"])) $sDOB = "'" . $_POST["DOBYear"] . "-" . $_POST["DOBMonth"] . "-" . substr("00" . $_POST["DOBDay"], -2) . "'";

	$iOfficeHead = 0;
	if (isset($_POST["OfficeHead"]) && ($_POST["OfficeHead"] == "y")) $iOfficeHead = 1;
	$iPrincipal = 0;
	if (isset($_POST["Principal"]) && ($_POST["Principal"] == "y")) $iPrincipal = 1;

	$sql = "INSERT INTO Contacts (ContactSurname, ContactInitials, ContactFirstName, ContactDesignation)
	VALUES ('" . addslashes($_POST["Surname"]) . "', 
	'" . addslashes($_POST["Initials"]) . "', '" . addslashes($_POST["FirstName"]) . "', 
	'" . addslashes($_POST["Designation"]) . "')";
	mysql_query($sql);

	// Get new ContactsID
	$query = "SELECT MAX(ContactsID) FROM Contacts AS ContactsID";
	$result = mysql_query($query) or die("Scope_Identity Failed");
	$row = mysql_fetch_array($result);
	$NewContactsID = $row[0];

	$sql = "INSERT INTO OfficeContacts (ContactsID, OfficeID, YPF, ContactPosition,
	OfficeHead, Principal, MandatedPrincipal, Mail) 
	VALUES ('" . $NewContactsID . "', '" . intval($_POST["OfficeID"]) . "', 'y', '" . addslashes($_POST["Position"]) . "',
	" . $iOfficeHead . ", " . $iPrincipal . ", 0, 0)";
	mysql_query($sql);

	$sql = "INSERT INTO MemberContacts (ContactID, OfficeID, ContactSurname, ContactInitials, ContactFirstName, ContactDesignation, YPF) 
	VALUES (" . $NewContactsID . ", " . intval($_POST["OfficeID"]) . ", '" . addslashes($_POST["Surname"]) . "', 
	'" . addslashes($_POST["Initials"]) . "', '" . addslashes($_POST["FirstName"]) . "', 
	'" . addslashes($_POST["Designation"]) . "', 'y')";
	mysql_query($sql);

	$sql = "UPDATE MemberContacts SET PersonalTel='" . addslashes($_POST["TelNum"]) . "', 
	PersonalFax='" . addslashes($_POST["PersonalFax"]) . "', CellPhone='" . addslashes($_POST["CellPhone"]) . "', 
	Email='" . addslashes($_POST["Email"]) . "', BirthDate=" . addslashes($sDOB) . ", 
	ContactPosition='" . addslashes($_POST["Position"]) . "',
	OfficeHead=" . $iOfficeHead . ", Principal=" . $iPrincipal . ", 
	MandatedPrincipal=0, Mail=0, YPF='y',
	ProfessionalRegistrations='" . addslashes($_POST["ProfReg"]) . "', 
	Qualifications='" . addslashes($_POST["Qual"]) . "',
	IDNumber='" . addslashes($_POST["IDNumber"]) . "', Comments='" . addslashes($_POST["Expertise"]) . "'
	WHERE ContactID = " . $NewContactsID;
	mysql_query($sql);

	$sql = "UPDATE Contacts SET PersonalTel='" . addslashes($_POST["TelNum"]) . "', 
	PersonalFax='" . addslashes($_POST["PersonalFax"]) . "', CellPhone='" . addslashes($_POST["CellPhone"]) . "', 
	PreferredEmail='" . addslashes($_POST["Email"]) . "', BirthDate=" . addslashes($sDOB) . ", 
	ProfessionalRegistrations='" . addslashes($_POST["ProfReg"]) . "', 
	Qualifications='" . addslashes($_POST["Qual"]) . "',
	IDNumber='" . addslashes($_POST["IDNumber"]) . "', Comments='" . addslashes($_POST["Expertise"]) . "'
	WHERE ContactsID = " . $NewContactsID;
	mysql_query($sql);

	echo "<p><b>Thank you. We have added your information to our database.</b></p>";

	if (!empty($_POST["Email"])) mail($_POST["Email"], "CESA YPF", "Thank you for joining the CESA YPF. Your details have been added to our database and we will send future relevant YPF communications to you at this email address.



Best regards,

The YPF Committee", "From: webmaster@cesa.co.za");

	$sql = "SELECT tblMemberFirms.FirmName, tblMemberFirmOffices.OfficeStatus, tblMemberFirmOffices.Province, tblMemberFirmOffices.GeoLocation
	FROM tblMemberFirms, tblMemberFirmOffices 
	WHERE tblMemberFirms.FirmID = tblMemberFirmOffices.FirmID AND tblMemberFirmOffices.OfficeID=" . intval($_POST["OfficeID"]);
	$recOffices = mysql_query($sql);
	$rowOffices = mysql_fetch_assoc($recOffices);

	$mailbody = "<p><b>YPF Contact information submitted on the CESA website:</b><br>
	<table border=1 width=600 cellspacing=0 cellpadding=10>
	<tr><td><b>Firm</b></td><td>" . $rowOffices["FirmName"] . "</td></tr>
	<tr><td><b>Office</b></td><td>" . $rowOffices["OfficeStatus"] . "-" . $rowOffices["Province"] . "-" . $rowOffices["GeoLocation"] . "</td></tr>
	<tr><td><b>Position</b></td><td>" . $_POST["Position"] . "</td></tr>
	<tr><td><b>Designation</b></td><td>" . $_POST["Designation"] . "</td></tr>
	<tr><td><b>Initials</b></td><td>" . $_POST["Initials"] . "</td></tr>
	<tr><td><b>First Name</b></td><td>" . $_POST["FirstName"] . "</td></tr>
	<tr><td><b>Surname</b></td><td>" . $_POST["Surname"] . "</td></tr>
	<tr><td><b>Tel Num</b></td><td>" . $_POST["TelNum"] . "</td></tr>
	<tr><td><b>Cell Num</b></td><td>" . $_POST["CellPhone"] . "</td></tr>
	<tr><td><b>Email Address</b></td><td>" . $_POST["Email"] . "</td></tr>
	<tr><td><b>Birth Date</b></td><td>" . $_POST["DOBDay"] . "/" . $_POST["DOBMonth"] . "/" . $_POST["DOBYear"] . "</td></tr>
	<tr><td><b>Professional Registrations</b></td><td>" . $_POST["ProfReg"] . "</td></tr>
	<tr><td><b>Qualifications</b></td><td>" . $_POST["Qual"] . "</td></tr>
	<tr><td><b>Fields of Expertise</b></td><td>" . $_POST["Expertise"] . "</td></tr>
	</table>
	";

	$headers  = 'MIME-Version: 1.0' . "\r\n";
	$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
	$headers .= 'From: webmaster@cesa.co.za' . "\r\n";

	mail("godfrey@cesa.co.za", "New YPF Contact", $mailbody, $headers);
} elseif (isset($_POST["selContact"])) {
	// Send email

	$mailbody = "<p>The following individual has registered on the website as a YPF member, but the information they supplied matches another contact already in the database. They have confirmed that they are already on the database with the information displayed below. <b>Please update the contact in the database with the newly provided information.</b></p>
	<p><b>Existing contact in the database:</b>
	";

	$sql = "SELECT Contacts.ContactsID, Contacts.ContactFirstName, Contacts.ContactSurname, Contacts.ContactInitials, 
	tblMemberFirms.FirmName, tblMemberFirmOffices.OfficeStatus, tblMemberFirmOffices.Province, tblMemberFirmOffices.GeoLocation
	FROM tblMemberFirms, tblMemberFirmOffices, OfficeContacts, Contacts
	WHERE tblMemberFirms.FirmID = tblMemberFirmOffices.FirmID
	AND tblMemberFirmOffices.OfficeID = OfficeContacts.OfficeID
	AND OfficeContacts.ContactsID = Contacts.ContactsID
	AND Contacts.ContactsID = " . intval($_POST["selContact"]);
	$recContacts = mysql_query($sql);
	if ($rowContacts = mysql_fetch_assoc($recContacts)) {
		$mailbody .= "
	<table border=1 width=600 cellspacing=0 cellpadding=10>
    <tr><td><b>Firm</b></td><td>" . $rowContacts["FirmName"] . "</td></tr>
	<tr><td><b>Office</b></td><td>" . $rowContacts["OfficeStatus"] . "-" . $rowContacts["Province"] . "-" . $rowContacts["GeoLocation"] . "</td></tr>
	<tr><td><b>Initials</b></td><td>" . $rowContacts["ContactInitials"] . "</td></tr>
	<tr><td><b>First Name</b></td><td>" . $rowContacts["ContactFirstName"] . "</td></tr>
	<tr><td><b>Surname</b></td><td>" . $rowContacts["ContactSurname"] . "</td></tr>
    </table>
	";
	}
	mysql_free_result($recContacts);

	$sql = "SELECT tblMemberFirms.FirmName, tblMemberFirmOffices.OfficeStatus, tblMemberFirmOffices.Province, tblMemberFirmOffices.GeoLocation
	FROM tblMemberFirms, tblMemberFirmOffices 
	WHERE tblMemberFirms.FirmID = tblMemberFirmOffices.FirmID AND tblMemberFirmOffices.OfficeID=" . intval($_POST["OfficeID"]);
	$recOffices = mysql_query($sql);
	$rowOffices = mysql_fetch_assoc($recOffices);

	$mailbody .= "</p>
	<p><b>New information provided on the website:</b><br>
	<table border=1 width=600 cellspacing=0 cellpadding=10>
    <tr><td><b>Firm</b></td><td>" . $rowOffices["FirmName"] . "</td></tr>
	<tr><td><b>Office</b></td><td>" . $rowOffices["OfficeStatus"] . "-" . $rowOffices["Province"] . "-" . $rowOffices["GeoLocation"] . "</td></tr>
	<tr><td><b>Designation</b></td><td>" . $_POST["Designation"] . "</td></tr>
	<tr><td><b>Initials</b></td><td>" . $_POST["Initials"] . "</td></tr>
	<tr><td><b>First Name</b></td><td>" . $_POST["FirstName"] . "</td></tr>
	<tr><td><b>Surname</b></td><td>" . $_POST["Surname"] . "</td></tr>
	<tr><td><b>Tel Num</b></td><td>" . $_POST["TelNum"] . "</td></tr>
	<tr><td><b>Fax Num</b></td><td>" . $_POST["PersonalFax"] . "</td></tr>
	<tr><td><b>Cell Num</b></td><td>" . $_POST["CellPhone"] . "</td></tr>
	<tr><td><b>Email Address</b></td><td>" . $_POST["Email"] . "</td></tr>
	<tr><td><b>Birth Date</b></td><td>" . $_POST["DOBDay"] . "/" . $_POST["DOBMonth"] . "/" . $_POST["DOBYear"] . "</td></tr>
    </table>
	";

	$headers  = 'MIME-Version: 1.0' . "\r\n";
	$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
	$headers .= 'From: webmaster@cesa.co.za' . "\r\n";

	mail("gillian@cesa.co.za", "New YPF member matches existing contact", $mailbody, $headers);

	echo "<p><b>Thank you. The updated information has been sent to us, so that we can update our database.</b></p>";

	if (!empty($_POST["Email"])) mail($_POST["Email"], "CESA YPF", "Thank you for joining the CESA YPF. Your details have been added to our database and we will send future relevant YPF communications to you at this email address.



Best regards,

The YPF Committee", "From: webmaster@cesa.co.za");
}
?>