Become a Volunteer
include(’/home/charity/public_html/admin/includes/config.php’);
include(’/home/charity/public_html/admin/includes/functions.php’);
if (isset($_REQUEST["submit"])){
$first_name=$_POST['first_name'];
$last_name=$_POST['last_name'];
$address=$_POST['address'];
$suburb=$_POST['suburb'];
$city=$_POST['city'];
$phone=str_replace(’ ‘,”,$_POST['phone']);
$mobile=str_replace(’ ‘,”,$_POST['mobile']);
$email=$_POST['email'];
$comments=$_POST['comments'];
$error=array();
$validemail = preg_match(’/^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+.([A-Za-z]{2,6}|[A-Za-z]{2,6}+.[A-Za-z]{2,6}|[A-Za-z]{2,6}+.[A-Za-z]{2,6}+.[A-Za-z]{2,6})$/i’,$_POST['email'])?true:false;
if (empty($first_name)) array_push($error,’First name cannot be blank’);
if (empty($last_name)) array_push($error,’Last name cannot be blank’);
if (empty($address)) array_push($error,’Address cannot be blank’);
if (empty($suburb)) array_push($error,’Suburb cannot be blank’);
if (empty($city)) array_push($error,’City cannot be blank’);
if (empty($phone)) array_push($error,’Phone number cannot be blank’);
if (empty($email)) array_push($error,’Email cannot be blank’);
elseif (!$validemail) array_push($error,’Email address is not valid.’);
$lookFor = array(’http’, ‘www’, ‘href’, ‘url’, ‘viagra’, ‘cialis’, ‘phentermine’, ‘levitra’, ’sex’, ‘penis’, ‘erection’, ‘pills’);
foreach ($lookFor as $value){
$pos = strpos(strtolower($_POST['comments']), strtolower($value));
if ($pos !== false){
array_push($error,’Your comments cannot contain the word ‘.$value.’, Please remove.’);
break;
}
}
$role_SetUp=$_POST['role_SetUp'];
$role_Registration=$_POST['role_Registration'];
$role_Timing=$_POST['role_Timing'];
$role_Food=$_POST['role_Food'];
$role_Safety=$_POST['role_Safety'];
$role_Marshals=$_POST['role_Marshals'];
$role_Drink=$_POST['role_Drink'];
$role_Ceremony=$_POST['role_Ceremony'];
$role_SetDown=$_POST['role_SetDown'];
$roles=array();
if(isset($role_SetUp)) array_push($roles,’Set Up’);
if(isset($role_Registration)) array_push($roles,’Registration’);
if(isset($role_Timing)) array_push($roles,’Timing’);
if(isset($role_Food)) array_push($roles,’Food Stalls’);
if(isset($role_Safety)) array_push($roles,’Safety’);
if(isset($role_Marshals)) array_push($roles,’Course Marshals’);
if(isset($role_Drink)) array_push($roles,’Drink Station Marshalls’);
if(isset($role_Ceremony)) array_push($roles,’Presentation Ceremony’);
if(isset($role_SetDown)) array_push($roles,’Set Down’);
if (count($error)==0){ //NO ERROR
//send email
$message = “Name: “.$first_name.” “.$last_name.”n”;
$message.= “Address:n”.$address.”n”.$suburb.”n”.$city.”nn”;
$message.= “Phone: “.$phone.”n”;
if(!empty($mobile))
$message.= “Mobile: “.$mobile.”n”;
if(count($roles)>0){
$message.= “Roles volunteered for:n”;
foreach ($roles as $value) {
$message.= $value .”n”;
}
}
$message.= “nVenues available for:n”;
while(list($key,$val)=each($_POST)){
if (substr($key,0,5)==”venue”){
$message.=”$valn”;
}
}
$message.= “nMessage:n”.$comments;
$headers = “From: ADRA Charity Run ” . “rn”;
$headers .= “Bcc: Webmaster ” . “rn”;
$headers .= “Reply-To: “.$first_name.” “.$last_name.” <”.$email.”>” . “rn”;
$sendto=’SherelleTorrey@adra.org.nz’;
//$sendto=’adrian@hodgeman.co.nz’; //TEST
mail($sendto,’New volunteer for ADRA Charity Run’,$message,$headers);
echo ”
Thank you “.$first_name.” for your interest in being involved with the ADRA Charity Run.
n”;
echo ”
Your information has been sent to the relevant events coordinator who will be in touch with you shortly.
n”;
echo ”
If you do not get a reply or you have any questions, please contact us.
n”;
}else{ //ERRORS FOUND
echo ”
echo ”
“.count($error).” Error/s
nt
- “;
- $value
foreach ($error as $value) {
echo “ntt
“;
}
echo “nt
n
“;
include (TEMPLATEPATH . ‘/formVolunteers.php’);
}
}else{
include (TEMPLATEPATH . ‘/formVolunteers.php’);
}
?>

