We help IT Professionals succeed at work.
Get Started

PHP Contact Form Multiple Attachments

480 Views
Last Modified: 2012-05-08
I am fairly new to PHP. I have a fully functioning contact form that submits to my email no problem. My issue is I need whoever fills out the form to be able to attach 2 files. My form script is below as well as a very simple solution which works perfectly on its own. I must be incorporating it wrong... any suggestions? (Also please remember I'm no PHP expert and realize my code is likely full of errors!)
----- MY CODE

<?php

                 $error    = ''; // error message
                 $firstname     = ''; 
                 $lastname     = ''; 
                 $email     = ''; 
                 $phone1    = ''; 
                 $phone2    = ''; 
                 $phone3    = ''; 
                 $altphone1    = ''; 
                 $altphone2   = ''; 
                 $altphone3    = ''; 
                 $address    = ''; 
                 $city    = ''; 
                 $date    = ''; 
                 $province    = ''; 
                 $postal    = ''; 
                 $subject  = ''; 
                 $who  = ''; 
                 $other  = ''; 
                 $media  = ''; 
                 $legal  = ''; 
                 $position    = ''; 
                 $criminal    = ''; 
                 $shift    = ''; 
                 $oncall    = ''; 
                 $school    = ''; 
                 $scname    = ''; 
                 $sccity    = ''; 
                 $degree    = ''; 
                 $scprovince    = ''; 
                 $more    = ''; 
                 $firstaid    = ''; 
                 $WHMIS    = ''; 
                 $H2S    = ''; 
                 $TDG    = ''; 
                 $confined    = ''; 
                 $certs    = ''; 
                 $driver    = ''; 
                 $provissued    = '';
                 $element_1_1    = ''; 
                 $element_1_2    = ''; 
                 $element_1_3    = '';                 
                 $element_2_1    = ''; 
                 $element_2_2    = ''; 
                 $element_2_3    = '';                  
                 $element_3_1    = ''; 
                 $element_3_2    = ''; 
                 $element_3_3    = '';                  
                 $element_4_1    = ''; 
                 $element_4_2    = ''; 
                 $element_4_3    = '';                  
                 $element_5_1    = ''; 
                 $element_5_2    = ''; 
                 $element_5_3    = '';                  
                 $element_6_1    = ''; 
                 $element_6_2    = ''; 
                 $element_6_3    = '';                  
                 $element_7_1    = ''; 
                 $element_7_2    = ''; 
                 $element_7_3    = ''; 
                 $class    = ''; 
                 $conditions    = ''; 
                 $experience    = ''; 
                 $company    = ''; 
                 $workphone1    = ''; 
                 $workphone2    = ''; 
                 $workphone3    = ''; 
                 $workphone4    = ''; 
                 $workphone5    = ''; 
                 $workphone6    = '';                  
                 $workphone7    = ''; 
                 $workphone8    = ''; 
                 $workphone9    = ''; 
                 $workcity    = ''; 
                 $workprov    = ''; 
                 $job    = ''; 
                 $supervisor    = ''; 
                 $start    = ''; 
                 $end    = ''; 
                 $reason    = ''; 
                 $contact    = ''; 
                 $company2    = ''; 
                 $workcity2    = ''; 
                 $workprov2    = ''; 
                 $job2    = ''; 
                 $supervisor2    = ''; 
                 $start2    = ''; 
                 $end2    = ''; 
                 $reason2    = ''; 
                 $contact2    = ''; 
                 $company3    = ''; 
                 $workcity3    = ''; 
                 $workprov3    = ''; 
                 $job3    = ''; 
                 $supervisor3    = ''; 
                 $start3    = ''; 
                 $end3    = ''; 
                 $reason3    = ''; 
                 $contact3    = ''; 
                 $accept    = ''; 
                    $spamcheck = '';
                 $EmailFrom = '';
// Select
    function select_options($option_values, $default_option){
        foreach ($option_values as $value => $text)
        {
            $is_selected = ($value == $default_option)? 'selected': '';
            $html_text = htmlspecialchars($text);  // in case text contains '&', etc.
            echo "<option value=\"$value\" $is_selected>$html_text</option>\n";
        }
    }  // End Select
    
$province = array('Choose One' => 'Choose One', 'Alberta' => 'Alberta', 'British Columbia' => 'British Columbia', 'Manitoba' => 'Manitoba', 'New Brunswick' => 'New Brunswick', 'Newfoundland and Labrador' => 'Newfoundland and Labrador', 'Northwest Territories' => 'Northwest Territories', 'Nova Scotia' => 'Nova Scotia', 'Nunavut' => 'Nunavut', 'Ontario' => 'Ontario', 'Prince Edward Island' => 'Prince Edward Island', 'Quebec' => 'Quebec', 'Saskatchewan' => 'Saskatchewan', 'Yukon' => 'Yukon');

$scprovince = array('Choose One' => 'Choose One', 'Alberta' => 'Alberta', 'British Columbia' => 'British Columbia', 'Manitoba' => 'Manitoba', 'New Brunswick' => 'New Brunswick', 'Newfoundland and Labrador' => 'Newfoundland and Labrador', 'Northwest Territories' => 'Northwest Territories', 'Nova Scotia' => 'Nova Scotia', 'Nunavut' => 'Nunavut', 'Ontario' => 'Ontario', 'Prince Edward Island' => 'Prince Edward Island', 'Quebec' => 'Quebec', 'Saskatchewan' => 'Saskatchewan', 'Yukon' => 'Yukon');        

$provissued = array('Choose One' => 'Choose One', 'Alberta' => 'Alberta', 'British Columbia' => 'British Columbia', 'Manitoba' => 'Manitoba', 'New Brunswick' => 'New Brunswick', 'Newfoundland and Labrador' => 'Newfoundland and Labrador', 'Northwest Territories' => 'Northwest Territories', 'Nova Scotia' => 'Nova Scotia', 'Nunavut' => 'Nunavut', 'Ontario' => 'Ontario', 'Prince Edward Island' => 'Prince Edward Island', 'Quebec' => 'Quebec', 'Saskatchewan' => 'Saskatchewan', 'Yukon' => 'Yukon');
            
$workprov1 = array('Choose One' => 'Choose One', 'Alberta' => 'Alberta', 'British Columbia' => 'British Columbia', 'Manitoba' => 'Manitoba', 'New Brunswick' => 'New Brunswick', 'Newfoundland and Labrador' => 'Newfoundland and Labrador', 'Northwest Territories' => 'Northwest Territories', 'Nova Scotia' => 'Nova Scotia', 'Nunavut' => 'Nunavut', 'Ontario' => 'Ontario', 'Prince Edward Island' => 'Prince Edward Island', 'Quebec' => 'Quebec', 'Saskatchewan' => 'Saskatchewan', 'Yukon' => 'Yukon');
                
$workprov2 = array('Choose One' => 'Choose One', 'Alberta' => 'Alberta', 'British Columbia' => 'British Columbia', 'Manitoba' => 'Manitoba', 'New Brunswick' => 'New Brunswick', 'Newfoundland and Labrador' => 'Newfoundland and Labrador', 'Northwest Territories' => 'Northwest Territories', 'Nova Scotia' => 'Nova Scotia', 'Nunavut' => 'Nunavut', 'Ontario' => 'Ontario', 'Prince Edward Island' => 'Prince Edward Island', 'Quebec' => 'Quebec', 'Saskatchewan' => 'Saskatchewan', 'Yukon' => 'Yukon');
                    
$workprov3 = array('Choose One' => 'Choose One', 'Alberta' => 'Alberta', 'British Columbia' => 'British Columbia', 'Manitoba' => 'Manitoba', 'New Brunswick' => 'New Brunswick', 'Newfoundland and Labrador' => 'Newfoundland and Labrador', 'Northwest Territories' => 'Northwest Territories', 'Nova Scotia' => 'Nova Scotia', 'Nunavut' => 'Nunavut', 'Ontario' => 'Ontario', 'Prince Edward Island' => 'Prince Edward Island', 'Quebec' => 'Quebec', 'Saskatchewan' => 'Saskatchewan', 'Yukon' => 'Yukon');
                    
$media = array('Choose One' => 'Choose One', 'SaskJobs.ca' => 'SaskJobs.ca', 'SaskatoonJobShop.com' => 'SaskatoonJobShop.com', 'WowJobs.ca' => 'WowJobs.ca', 'Canada.com' => 'Canada.com', 'Yellow Pages' => 'Yellow Pages', 'U of Saskatchewan' => 'U of Saskatchewan', 'U of Regina' => 'U of Regina', 'SIAST' => 'SIAST', 'APEGS' => 'APEGS', 'ECO Canada Career Site' => 'ECO Canada Career Site', 'Saskatchewan Trucking Assoc.' => 'Saskatchewan Trucking Assoc.', 'Friend/Family' => 'Friend/Family', 'Other' => 'Other');
                                        
$position = array('Choose One' => 'Choose One', 'Health and Safety Officer' => 'Health and Safety Officer');

$school = array('Choose One' => 'Choose One', 'No High School/GED' => 'No High School/GED', 'High School/GED' => 'High School/GED', 'College' => 'College', 'Tech School' => 'Tech School', 'University' => 'University');
            if(isset($_POST['send']))
            {
                 $firstname     = $_POST['firstname'];
                 $lastname     = $_POST['lastname'];
                 $email    = $_POST['email'];
                 $phone1    = $_POST['phone1'];
                 $phone2    = $_POST['phone2'];
                 $phone3    = $_POST['phone3'];
                 $altphone1    = $_POST['altphone1'];
                 $altphone2    = $_POST['altphone2'];
                 $altphone3    = $_POST['altphone3'];
                 $address    = $_POST['address'];
                 $city    = $_POST['city'];
                 $prov_select = $_POST['province'];
                 $postal    = $_POST['postal'];
                 $position_select   = $_POST['position'];
                 $date  = $_POST['date'];
                 $media_select  = $_POST['media'];
                 $who  = $_POST['who'];
                 $other  = $_POST['other'];
                 $legal  = $_POST['legal'];
                 $criminal  = $_POST['criminal'];
                 $shift  = $_POST['shift'];
                 $oncall  = $_POST['oncall'];
                 $school_select  = $_POST['school'];
                 $scname  = $_POST['scname'];
                 $sccity  = $_POST['sccity'];
                 $degree  = $_POST['degree'];
                 $scprovince_select  = $_POST['scprovince'];
                 $more  = $_POST['more'];
                 $firstaid  = $_POST['firstaid'];
                 $WHMIS  = $_POST['WHMIS'];
                 $H2S  = $_POST['H2S'];
                 $TDG  = $_POST['TDG'];
                    $confined  = $_POST['confined'];
                    $certs  = $_POST['certs'];
                    $driver  = $_POST['driver'];
                    $provissued_select  = $_POST['provissued'];
                    $class  = $_POST['class'];
                    $conditions  = $_POST['conditions'];
                    $experience  = $_POST['experience'];
                    $company  = $_POST['company'];
                    $workphone1  = $_POST['workphone1'];
                    $workphone2  = $_POST['workphone2'];
                    $workphone3  = $_POST['workphone3'];                    
                 $workphone4  = $_POST['workphone4'];
                    $workphone5  = $_POST['workphone5'];
                    $workphone6  = $_POST['workphone6'];                 
                 $workphone7  = $_POST['workphone7'];
                    $workphone8  = $_POST['workphone8'];
                    $workphone9  = $_POST['workphone9'];
                    $workcity  = $_POST['workcity'];
                    $workprov_select  = $_POST['workprov1'];
                    $job  = $_POST['job'];
                    $supervisor  = $_POST['supervisor'];
                    $experience  = $_POST['experience'];
                    $start  = $_POST['start'];
                    $end  = $_POST['end'];
                    $reason  = $_POST['reason'];
                    $contact  = $_POST['contact'];
                 $company2  = $_POST['company2'];
                    $workcity2  = $_POST['workcity2'];
                    $workprov2_select  = $_POST['workprov2'];
                    $job2  = $_POST['job2'];
                    $supervisor2  = $_POST['supervisor2'];
                    $experience2  = $_POST['experience2'];
                    $start2  = $_POST['start2'];
                    $end2  = $_POST['end2'];
                    $reason2  = $_POST['reason2'];
                    $contact2  = $_POST['contact2'];
                 $company3  = $_POST['company3'];
                    $workcity3  = $_POST['workcity3'];
                    $workprov3_select  = $_POST['workprov3'];
                    $job3  = $_POST['job3'];
                    $supervisor3  = $_POST['supervisor3'];
                    $experience3  = $_POST['experience3'];
                    $start3  = $_POST['start3'];
                    $end3  = $_POST['end3'];
                    $reason3  = $_POST['reason3'];
                    $contact3  = $_POST['contact3'];
                    $accept  = $_POST['accept'];
                 $spamcheck = $_POST['spamcheck'];
                 $element_1_3 = $_POST['element_1_3'];
                 $element_1_1 = $_POST['element_1_1'];
                 $element_1_2 = $_POST['element_1_2'];    
                 $element_4_3 = $_POST['element_4_3'];
                 $element_4_1 = $_POST['element_4_1'];
                 $element_4_2 = $_POST['element_4_2'];    
                 $element_2_3 = $_POST['element_2_3'];
                 $element_2_1 = $_POST['element_2_1'];
                 $element_2_2 = $_POST['element_2_2'];                 
                 $element_3_3 = $_POST['element_3_3'];
                 $element_3_1 = $_POST['element_3_1'];
                 $element_3_2 = $_POST['element_3_2'];
                 $element_5_3 = $_POST['element_5_3'];
                 $element_5_1 = $_POST['element_5_1'];
                 $element_5_2 = $_POST['element_5_2'];
                 $element_6_3 = $_POST['element_6_3'];
                 $element_6_1 = $_POST['element_6_1'];
                 $element_6_2 = $_POST['element_6_2'];                 
                 $element_7_3 = $_POST['element_7_3'];
                 $element_7_1 = $_POST['element_7_1'];
                 $element_7_2 = $_POST['element_7_2'];
                 $EmailFrom = "applications@envirotec.ca";

                                if(trim($element_1_1) == '')
                {
                    $error = '<div class="errormsg">Please enter the date you are available!</div>';
                }
                if(trim($element_1_2) == '')
                {
                    $error = '<div class="errormsg">Please enter the date you are available!</div>';
                }
                
                
                if(trim($element_1_3) == '')
                {
                    $error = '<div class="errormsg">Please enter the date you are available!</div>';
                }
                
                if(trim($element_3_1) == '')
                {
                    $error = '<div class="errormsg">Please enter the end date of your last job!</div>';
                }
                if(trim($element_3_2) == '')
                {
                    $error = '<div class="errormsg">Please enter the end date of your last job!</div>';
                }
                if(trim($element_3_3) == '')
                {
                    $error = '<div class="errormsg">Please enter the end date of your last job!</div>';
                }
                
                if(trim($element_2_1) == '')
                {
                    $error = '<div class="errormsg">Please enter the start date of your last job!</div>';
                }
                if(trim($element_2_2) == '')
                {
                    $error = '<div class="errormsg">Please enter the start date of your last job!</div>';
                }
                if(trim($element_2_3) == '')
                {
                    $error = '<div class="errormsg">Please enter the start date of your last job!</div>';
                }
                                                    if(trim($firstname) == '')
                {
                    $error = '<div class="errormsg">Please enter your first name!</div>';
                }
                                if(trim($lastname) == '')
                {
                    $error = '<div class="errormsg">Please enter your last first name!</div>';
                }
                    else if(trim($email) == '')
                {
                    $error = '<div class="errormsg">Please enter your email address!</div>';
                }
                else if(!isEmail($email))
                {
                    $error = '<div class="errormsg">You have enter an invalid e-mail address. Please, try again!</div>';
                }
                                if(trim($phone3) == '')
                {
                    $error = '<div class="errormsg">Please enter your phone number!</div>';
                }
                if(trim($phone2) == '')
                {
                    $error = '<div class="errormsg">Please enter your phone number!</div>';
                }
                                if(trim($address) == '')
                {
                    $error = '<div class="errormsg">Please enter your street address!</div>';
                }
                                if(trim($city) == '')
                {
                    $error = '<div class="errormsg">Please enter your city!</div>';
                }
                                if(trim($province) == 'Choose One')
                {
                    $error = '<div class="errormsg">Please select your province!</div>';
                }
                if(trim($postal) == '')
                {
                    $error = '<div class="errormsg">Please enter your postal code!</div>';
                }                if(trim($legal) == '')
                {
                    $error = '<div class="errormsg">Please indicate if you are legally eligible to work in Canada!</div>';
                }
                    if(trim($position) == 'Choose One')
                {
                    $error = '<div class="errormsg">Please select the position you are applying for!</div>';
                }
                
                if(trim($media) == 'Choose One')
                {
                    $error = '<div class="errormsg">Please select how you heard about us!</div>';
                }
                
                if(trim($school) == 'Choose One')
                {
                    $error = '<div class="errormsg">Please specify the highest level of education recieved!</div>';
                }
                if(trim($criminal) == '')
                {
                    $error = '<div class="errormsg">Please indicate if you have been convicted of a criminal offence!</div>';
                }
                
                if(trim($scname) == '')
                {
                    $error = '<div class="errormsg">Please enter your school name!</div>';
                }
                
                if(trim($sccity) == '')
                {
                    $error = '<div class="errormsg">Please enter your school city!</div>';
                }
                
                
                if(trim($degree) == '')
                {
                    $error = '<div class="errormsg">Please specify your degree!</div>';
                }
                
                if(trim($scprovince) == '')
                {
                    $error = '<div class="errormsg">Please select your school province!</div>';
                }
                                if(trim($firstaid) == '')
                {
                    $error = '<div class="errormsg">Please indicate whether or not you have a first aid certificate!</div>';
                }
                
                                if(trim($firstaid) == '')
                {
                    $error = '<div class="errormsg">Please indicate whether or not you have a first aid certificate!</div>';
                }
                
                                                if(trim($WHMIS) == '')
                {
                    $error = '<div class="errormsg">Please indicate whether or not you have a WHMIS certificate!</div>';
                }
                
                                                if(trim($H2S) == '')
                {
                    $error = '<div class="errormsg">Please indicate whether or not you have a H2S certificate!</div>';
                }
                
                                                if(trim($TDG) == '')
                {
                    $error = '<div class="errormsg">Please indicate whether or not you have a TDG certificate!</div>';
                }
                
                                                if(trim($confined) == '')
                {
                    $error = '<div class="errormsg">Please indicate whether or not you have a Confined Space Entry certificate!</div>';
                }
                        if(trim($company) == '')
                {
                    $error = '<div class="errormsg">Please enter the name of your previous employer!</div>';
                }
                
                        if(trim($workphone2) == '')
                {
                    $error = '<div class="errormsg">Please enter the phone number of your previous employer!</div>';
                }
                
                if(trim($workphone3) == '')
                {
                    $error = '<div class="errormsg">Please enter the phone number of your previous employer!</div>';
                }
                
                    if(trim($workcity) == '')
                {
                    $error = '<div class="errormsg">Please enter the city of your previous employer!</div>';
                }
                
                    if(trim($workprov1) == 'Choose One')
                {
                    $error = '<div class="errormsg">Please select the province of your previous employer!</div>';
                }
                                else if(trim($phone3) == '')
                {
                    $error = '<div class="errormsg">Please enter your phone number!</div>';
                }
                else if(trim($phone2) == '')
                {
                    $error = '<div class="errormsg">Please enter your phone number!</div>';
                }
                
                
                else if(trim($phone1) == '')
                {
                    $error = '<div class="errormsg">Please enter your phone number!</div>';
                }

                
                                else if(!preg_match("/^[0-9]{3,}$/",$phone1))
                {
                    $error = '<div class="errormsg">Please enter a valid phone number!</div>';
                }
                
                else if(!preg_match("/^[0-9]{3,}$/",$phone2))
                {
                    $error = '<div class="errormsg">Please enter a valid phone number!</div>';
                }
                
                else if(!preg_match("/^[0-9]{4,}$/",$phone3))
                {
                    $error = '<div class="errormsg">Please enter a valid phone number!</div>';
                }                                else if(!preg_match("/^[0-9]{3,}$/",$workphone1))
                {
                    $error = '<div class="errormsg">Please enter a valid phone number for your previous employer!</div>';
                }
                
                else if(!preg_match("/^[0-9]{3,}$/",$workphone2))
                {
                    $error = '<div class="errormsg">Please enter a valid phone number for your previous employer!</div>';
                }
                
                else if(!preg_match("/^[0-9]{4,}$/",$workphone3))
                {
                    $error = '<div class="errormsg">Please enter a valid phone number for your previous employer!</div>';
                }
                
                
                    if(trim($reason) == '')
                {
                    $error = '<div class="errormsg">Please indicate reason for leaving your previous employment!</div>';
                }
                
                                    if(trim($contact) == '')
                {
                    $error = '<div class="errormsg">Please specify if we are able to contact your previous employer!</div>';
                }
                                
                                    if(trim($accept) == '')
                {
                    $error = '<div class="errormsg">Please review our privacy policy!</div>';
                }
                                
                                    if(trim($accept) == 'No')
                {
                    $error = '<div class="errormsg">If you do not accept our privacy policy your application can not be processed by this means.</div>';
                }
                
                
                  else if(trim($spamcheck) == '')
                {
                    $error = '<div class="errormsg">Please enter the number for Spam Check!</div>';
                }
                  else if(trim($spamcheck) != '5')
                {
                    $error = '<div class="errormsg">Spam Check: The number you entered is not correct! 2 + 3 = ???</div>';
                }
                if($error == '')
                {
                    if(get_magic_quotes_gpc())
                    {
                        $message = stripslashes($message);
                    }
                    
                    $to      = "myemail@hotmail.com";// CHANGE!!!

                    $subject = 'Employment Application';

                    // the mail message
                    
                        $msg     = "\r\nPERSONAL INFORMATION";
            $msg     .= "\r\n ";
            $msg     .= "\r\nFirst Name: " . $firstname;
            $msg     .= "\r\nLast Name: " . $lastname;
            $msg     .= "\r\nEmail: " . $email;
            $msg     .= "\r\nPhone Number: " . $phone1;
            $msg     .= " " . $phone2;
            $msg     .= " " . $phone3;
            $msg     .= "\r\nProvince: " . $_POST['province'];
            $msg     .= "\r\nPostal Code: " . $postal;
            $msg     .= "\r\nHow did you hear about us? " . $_POST['media'];    
            $msg     .= "\r\nIf family/friend who? " . $who;
            $msg     .= "\r\nOther: " . $other;
            $msg     .= "\r\nDate Available: " . $element_1_1;            
            $msg     .= " " . $element_1_2;
            $msg     .= " " . $element_1_3;
            $msg     .= "\r\nPosition Applied For: " . $_POST['position'];    
            $msg     .= "\r\nLegally eligible to work in Canada? " . $legal;
            $msg     .= "\r\nHave you been convicted of a criminal offence? " . $criminal;
            $msg     .= "\r\nAvailable for shift work? " . $shift;            
            $msg     .= "\r\nOn call 24 hours? " . $oncall;
            $msg     .= "\r\n ";
            $msg     .= "\r\nEDUCATIONAL INFORMATION";
            $msg     .= "\r\n ";
            $msg     .= "\r\nHighest Level Completed: " . $_POST['school'];    
            $msg     .= "\r\nSchool Name: " . $scname;
            $msg     .= "\r\nCity: " . $sccity;
            $msg     .= "\r\nProvince: " . $_POST['scprovince'];    
            $msg     .= "\r\nDegree: " . $degree;
            $msg     .= "\r\nAdditional Information: " . $more;
            $msg     .= "\r\n ";
            $msg     .= "\r\nCERTIFICATES";
            $msg     .= "\r\n ";
            $msg     .= "\r\nFirst Aid: " . $firstaid;
            $msg     .= "\r\nWHMIS: " . $WHMIS;
            $msg     .= "\r\nH2S: " . $H2S;
            $msg     .= "\r\nTDG: " . $TDG;
            $msg     .= "\r\nConfined Space Entry: " . $confined;
            $msg     .= "\r\nOther Certificates: " . $certs;
            $msg     .= "\r\n ";
            $msg     .= "\r\nDRIVING EXPERIENCE";
            $msg     .= "\r\n ";
            $msg     .= "\r\nValid Driver's License: " . $driver;
            $msg     .= "\r\nProvince Issued: " . $_POST['provissued'];    
            $msg     .= "\r\nClass: " . $class;
            $msg     .= "\r\nConditions or Restrictions: " . $conditions;
            $msg     .= "\r\nExperience: " . $experience;
            $msg     .= "\r\n ";
            $msg     .= "\r\nPREVIOUS EMPLOYMENT";
            $msg     .= "\r\n ";
            $msg     .= "\r\nCompany Name: " . $company;
            $msg     .= "\r\nPhone Number: " . $workphone1;
            $msg     .= " " . $workphone2;
            $msg     .= " " . $workphone3;
            $msg     .= "\r\nCity: " . $workcity;
            $msg     .= "\r\nProvince: " . $_POST['workprov1'];    
            $msg     .= "\r\nDuties and Responsibilities: " . $job;
            $msg     .= "\r\nSupervisors Name: " . $supervisor;
            $msg     .= "\r\nStart Date: " . $element_2_1;            
            $msg     .= " " . $element_2_2;
            $msg     .= " " . $element_2_3;
            $msg     .= "\r\nEnd Date: " . $element_3_1;            
            $msg     .= " " . $element_3_2;
            $msg     .= " " . $element_3_3;
            $msg     .= "\r\nReason for Leaving: " . $reason;
            $msg     .= "\r\nMay we contact this employer? " . $contact;
            $msg     .= "\r\n ";
            $msg     .= "\r\nCompany Name: " . $company2;
            $msg     .= "\r\nPhone Number: " . $workphone4;
            $msg     .= " " . $workphone5;
            $msg     .= " " . $workphone6;
            $msg     .= "\r\nCity: " . $workcity2;
            $msg     .= "\r\nProvince: " . $_POST['workprov2'];    
            $msg     .= "\r\nDuties and Responsibilities: " . $job2;
            $msg     .= "\r\nSupervisors Name: " . $supervisor2;
            $msg     .= "\r\nStart Date: " . $element_4_1;            
            $msg     .= " " . $element_4_2;
            $msg     .= " " . $element_4_3;
            $msg     .= "\r\nEnd Date: " . $element_5_1;            
            $msg     .= " " . $element_5_2;
            $msg     .= " " . $element_5_3;
            $msg     .= "\r\nReason for Leaving: " . $reason2;
            $msg     .= "\r\nMay we contact this employer: " . $contact2;
            $msg     .= "\r\n ";
            $msg     .= "\r\nCompany Name: " . $company3;
            $msg     .= "\r\nPhone Number: " . $workphone7;
            $msg     .= " " . $workphone8;
            $msg     .= " " . $workphone9;
            $msg     .= "\r\nCity: " . $workcity3;
            $msg     .= "\r\nProvince: " . $_POST['workprov3'];    
            $msg     .= "\r\nDuties and Responsibilities: " . $job3;
            $msg     .= "\r\nSupervisors Name: " . $supervisor3;
            $msg     .= "\r\nStart Date: " . $element_6_1;            
            $msg     .= " " . $element_6_2;
            $msg     .= " " . $element_6_3;
            $msg     .= "\r\nEnd Date: " . $element_7_1;            
            $msg     .= " " . $element_7_2;
            $msg     .= " " . $element_7_3;
            $msg     .= "\r\nReason for Leaving: " . $reason4;
            $msg     .= "\r\nMay we contact this employer: " . $contact4;

                    mail($to, $subject, $msg, "From: <$EmailFrom>");
            ?>

                  <!-- Message sent! (change the text below as you wish)-->
              <div>
                       <p>Thank you <b><?=$firstname;?></b>, for your interest in Envirotec Services Incorporated! Your application has been received and will be considered in due course. Unfortunately, due to the volume of applications, only applicants that have been selected for interview can be contacted. </p>
                       <p>For more information on Envirotec, or to view additional opportunities, please visit email <a href="mailto:&#104;&#117;&#109;&#097;&#110;&#114;&#101;&#115;&#111;&#117;&#114;&#099;&#101;&#115;&#064;&#101;&#110;&#118;&#105;&#114;&#111;&#116;&#101;&#099;&#046;&#099;&#097;">&#104;&#117;&#109;&#097;&#110;&#114;&#101;&#115;&#111;&#117;&#114;&#099;&#101;&#115;&#064;&#101;&#110;&#118;&#105;&#114;&#111;&#116;&#101;&#099;&#046;&#099;&#097;</a>. </p>
                       <br/><br/><br/>
                  </div>
                  <!--End Message Sent-->


            <?php
                }
            }

            if(!isset($_POST['send']) || $error != '')
            {
            ?>
            <!--Error Message-->
            <br/><span class="required"><?=$error;?></span><br/>
<table>
            <tr>
                <td class="setwidth"><div class="sub_head" style="padding-bottom: 8px;">Personal Information</div></td></tr>
            <form  method="POST" action="" enctype="multipart/form-data">

                      <tr><td class="setwidth"><label>First Name: <span class="required">*</span> </label></td>
                        <td width="253"><input name="firstname" type="text" class="box" id="firstname" size="30" value="<?=$firstname;?>" /></td></tr>
                        
                        <tr><td class="setwidth"><label>Last Name: <span class="required">*</span> </label></td>
                        <td><input name="lastname" type="text" class="box" id="lastname" size="30" value="<?=$lastname;?>" /></td></tr>

                         <tr><td class="setwidth"><label>Email: <span class="required">*</span> </label></td>
                        <td><input name="email" type="text" class="box" id="email" size="30" value="<?=$email;?>" /></td></tr>

 <tr><td class="setwidth"><label>Phone Number: <span class="required">*</span> </label></td>
                 <td>
            <input id="phone1" name="phone1" size="3" maxlength="3" type="text" value="<?=$phone1;?>" > -        
        
            <input id="phone2" name="phone2" size="3" maxlength="3" type="text" value="<?=$phone2;?>"> -        

            <input id="phone3" name="phone3" size="4" maxlength="4" type="text" value="<?=$phone3;?>">        

    </td></tr>                        
 <tr><td class="setwidth"><label>Alternate Phone Number: </label></td>
                 <td>
            <input id="altphone1" name="altphone1" size="3" maxlength="3" type="text" value="<?=$altphone1;?>"> -        
        
            <input id="altphone2" name="altphone2" size="3" maxlength="3" type="text" value="<?=$altphone2;?>"> -        

            <input id="altphone3" name="altphone3" size="4" maxlength="4" type="text" value="<?=$altphone3;?>">        

    </td></tr>     
                        
                        <tr><td class="setwidth"><label>Street Address: <span class="required">*</span> </label></td>
                        <td><input name="address" type="text" class="box" id="address" size="30" value="<?=$address;?>" /></td></tr> 
                       
                       <tr><td class="setwidth"><label>City/Town: <span class="required">*</span> </label></td>
                        <td><input name="city" type="text" class="box" id="city" size="30" value="<?=$city;?>" /></td></tr> 
      
                        <tr><td class="setwidth"><label>Province: <span class="required">*</span> </label></td>
                        <td>                      
    <select name="province" id="province">
        <?= select_options($province, $_POST['province']) ?>
    </select>
                        </td></tr>
                        
                        
                        <tr><td class="setwidth"><label>Postal Code: <span class="required">*</span> </label></td>
                        <td><input name="postal" type="text" class="box" id="postal" size="7" maxlength="7" value="<?=$postal;?>" /></td></tr> 
                                            <tr><td class="setwidth"><label>How did you hear about us? <span class="required">*</span> </label></td>
                        <td>                      
<select name="media" id="media">                
        <?= select_options($media, $_POST['media']) ?>
                        </select>
                        </td></tr>
                        
                        <tr><td class="setwidth"><label>If you selected Friend/Family, please specify who. </label></td>
                        <td><input name="who" type="text" class="box" id="who" size="30" value="<?=$who;?>" /></td></tr>
                        
                        <tr><td class="setwidth"><label>If you selected Other, please specify.</label></td>
                        <td><input name="other" type="text" class="box" id="other" size="30" value="<?=$other;?>" /></td></tr>
                                                 <tr><td>&nbsp;</td></tr> 
             <tr><td style="border-top: thin #ccc solid;" colspan="2">&nbsp;</td></tr> 
                    <tr>
                <td class="setwidth"><div class="sub_head" style="padding-bottom: 8px;">Employment Information</div></td></tr>


<tr><td>        <label>Date Available: <span class="required">*</span> </label></td><td> 

        <span>
            <input id="element_1_1" name="element_1_1" class="element text" size="2" maxlength="2" value="<?=$element_1_1;?>" type="text"> /
            <label for="element_1_1">MM</label>
        </span>
        <span>
            <input id="element_1_2" name="element_1_2" class="element text" size="2" maxlength="2" value="<?=$element_1_2;?>" type="text"> /
            <label for="element_1_2">DD</label>
        </span>
        <span>
             <input id="element_1_3" name="element_1_3" class="element text" size="4" maxlength="4" value="<?=$element_1_3;?>" type="text">
            <label for="element_1_3">YYYY</label>
        </span>
    
        <span id="calendar_1">
            <img id="cal_img_1" class="datepicker" src="../images/calendar.gif" alt="calendar">    
        </span>
        <script type="text/javascript">
            Calendar.setup({
            inputField     : "element_1_3",
            baseField    : "element_1",
            displayArea  : "calendar_1",
            button         : "cal_img_1",
            ifFormat     : "%B %e, %Y",
            onSelect     : selectDate
            });
        </script>
         </td></tr>


<!--UPDATE JOBS!!!-->               


                   <tr><td class="setwidth"><label>Position Applied For: <span class="required">*</span> </label></td>
                        <td>                      
<select name="position" id="position">                
        <?= select_options($position, $_POST['position']) ?>
                        </select>
                        </td></tr> 
                   <tr><td class="setwidth"><label>Are you legally eligible to work in Canada? <span class="required">*</span> </label></td>
<td><input type="radio" name="legal" value="Yes">Yes
<input type="radio" name="legal" value="No">No </td></tr>

                   <tr><td class="setwidth"><label>Have you ever been convicted of a Criminal Offence for which a pardon has not been granted? <span class="required">*</span> </label></td>
<td><input type="radio" name="criminal" value="Yes">Yes
<input type="radio" name="criminal" value="No">No </td></tr>

                   <tr><td class="setwidth"><label>Are you available for shift work?</label></td>
<td><input type="radio" name="shift" value="Yes">Yes
<input type="radio" name="shift" value="No">No </td></tr>

                   <tr><td class="setwidth"><label>Are you available for 24 hour on call status?</label></td>
<td><input type="radio" name="oncall" value="Yes">Yes
<input type="radio" name="oncall" value="No">No </td></tr>
                                                                                       <tr><td>&nbsp;</td></tr> 
             <tr><td style="border-top: thin #ccc solid;" colspan="2">&nbsp;</td></tr> 

                    <tr>
                <td class="setwidth"><div class="sub_head" style="padding-bottom: 8px;">Education</div></td></tr>

                <tr><td class="setwidth"><label>Highest Level Completed: <span class="required">*</span> </label></td>
                        <td>                      
<select name="school" id="school">                
        <?= select_options($school, $_POST['school']) ?>
                        </select>
                        </td></tr>
                        
                   <tr><td class="setwidth"><label>School Name: <span class="required">*</span> </label></td>
                        <td><input name="scname" type="text" class="box" id="scname" size="30" value="<?=$scname;?>" /></td></tr> 
                        
                   <tr><td class="setwidth"><label>City/Town: <span class="required">*</span> </label></td>
                        <td><input name="sccity" type="text" class="box" id="sccity" size="30" value="<?=$sccity;?>" /></td></tr> 
                        
                  <tr><td class="setwidth"><label>Province: <span class="required">*</span> </label></td>
                        <td>                      
<select name="scprovince" id="scprovince">                
        <?= select_options($scprovince, $_POST['scprovince']) ?>
                        </select>
                        </td></tr>      
                        
                    <tr><td class="setwidth"><label>Degree/Diploma (or highest level achieved): <span class="required">*</span> </label></td>
                        <td><input name="degree" type="text" class="box" id="degree" size="30" value="<?=$degree;?>" /></td></tr> 
                        
                     <tr><td valign="top" class="setwidth"><label>Please indicate any relevant skills, expertise, or accreditation.</label></td>
                     <td><textarea name="more" cols="30" rows="6"  id="more"><?=$more;?></textarea></td></tr>
                        
                                                           <tr><td>&nbsp;</td></tr> 
             <tr><td style="border-top: thin #ccc solid;" colspan="2">&nbsp;</td></tr>  

                    <tr>
                <td class="setwidth"><div class="sub_head" style="padding-bottom: 8px;">Licenses and Certificates</div></td></tr>
                
               <tr><td class="setwidth" colspan="2"><label>Do you have any of the following certificates?</label></td></tr>
               
                <tr><td class="setwidth"><label>First Aid <span class="required">*</span> </label></td>
<td><input type="radio" name="firstaid" value="Yes">Yes
<input type="radio" name="firstaid" value="No">No </td></tr>

                <tr><td class="setwidth"><label>WHMIS <span class="required">*</span> </label></td>
<td><input type="radio" name="WHMIS" value="Yes">Yes
<input type="radio" name="WHMIS" value="No">No </td></tr>

                <tr><td class="setwidth"><label>H2S <span class="required">*</span> </label></td>
<td><input type="radio" name="H2S" value="Yes">Yes
<input type="radio" name="H2S" value="No">No </td></tr>

                <tr><td class="setwidth"><label>TDG <span class="required">*</span> </label></td>
<td><input type="radio" name="TDG" value="Yes">Yes
<input type="radio" name="TDG" value="No">No </td></tr>

                <tr><td class="setwidth"><label>Confined Space Entry <span class="required">*</span> </label></td>
<td><input type="radio" name="confined" value="Yes">Yes
<input type="radio" name="confined" value="No">No </td></tr>

                   <tr><td class="setwidth"><label>Please indicate any other relevant certification. </label></td>
                        <td><input name="certs" type="text" class="box" id="certs" size="30" value="<?=$certs;?>" /></td></tr> 
                        
                                                                                      <tr><td>&nbsp;</td></tr> 
             <tr><td style="border-top: thin #ccc solid;" colspan="2">&nbsp;</td></tr> 

                    <tr>
                <td class="setwidth"><div class="sub_head">Driving Experience</div></td></tr>
                        
                    <tr><td class="setwidth" colspan="2" style="padding-bottom: 8px"><label>Please fill out only if applying for a driving position.</label></td></tr>
                
                <tr><td class="setwidth"><label>Do you have a valid driver's license?</label></td>
<td><input type="radio" name="driver" value="Yes">Yes
<input type="radio" name="driver" value="No">No </td></tr>
                  <tr><td class="setwidth"><label>Province Issued: </label></td>
                        <td>                      
<select name="provissued" id="provissued">                
        <?= select_options($provissued, $_POST['provissued']) ?>
                        </select>
                        </td></tr>      
                        
                   <tr><td class="setwidth"><label>Class: </label></td>
                        <td><input name="class" type="text" class="box" id="class" size="4" value="<?=$class;?>" /></td></tr> 
                        
                                      <tr><td class="setwidth"><label>Restrictions or Conditions: </label></td>
                        <td><input name="conditions" type="text" class="box" id="conditions" size="30" value="<?=$conditions;?>" /></td></tr> 
                        
                                          <tr><td valign="top" class="setwidth"><label>Please indicate what type of driving experience you have.</label></td>
                     <td><textarea name="experience" cols="30" rows="6"  id="experience"><?=$experience;?></textarea></td></tr>
                
                                                     <tr><td>&nbsp;</td></tr> 
             <tr><td style="border-top: thin #ccc solid;" colspan="2">&nbsp;</td></tr>  

                    <tr>
                <td class="setwidth"><div class="sub_head">Previous Employment</div></td></tr>
                                    <tr><td class="setwidth" colspan="2" style="padding-bottom: 8px"><label>Please start with the most recent position first.</label></td></tr>

               <tr><td class="setwidth"><label>Company Name: <span class="required">*</span> </label></td>
                        <td><input name="company" type="text" class="box" id="company" size="30" value="<?=$company;?>" /></td></tr> 
               
              <tr><td class="setwidth"><label>Phone Number: <span class="required">*</span> </label></td>
                 <td>
            <input id="workphone1" name="workphone1" size="3" maxlength="3" type="text" value="<?=$workphone1;?>"> -        
        
            <input id="workphone2" name="workphone2" size="3" maxlength="3"  type="text" value="<?=$workphone2;?>"> -        

            <input id="workphone3" name="workphone3" size="4" maxlength="4"  type="text" value="<?=$workphone3;?>">        

    </td></tr>  
                   <tr><td class="setwidth"><label>City/Town: <span class="required">*</span> </label></td>
                        <td><input name="workcity" type="text" class="box" id="workcity" size="30" value="<?=$workcity;?>" /></td></tr> 
                        
                  <tr><td class="setwidth"><label>Province: <span class="required">*</span> </label></td>
                        <td>                      
<select name="workprov1" id="workprov1">                
        <?= select_options($workprov1, $_POST['workprov1']) ?>
                        </select>
                        </td></tr>    
                        
                 <tr><td class="setwidth"><label>Supervisor's Name: </label></td>
                        <td><input name="supervisor" type="text" class="box" id="supervisor" size="30" value="<?=$supervisor;?>" /></td></tr> 
                  
                  <tr><td valign="top" class="setwidth"><label>Description of Job Duties and Responsibilities:</label></td>
                     <td><textarea name="job" cols="30" rows="6"  id="job"><?=$job;?></textarea></td></tr>
                        
<tr><td> <label>Start Date: <span class="required">*</span> </label></td><td>
        <span>
            <input id="element_2_1" name="element_2_1" class="element text" size="2" maxlength="2"value="<?=$element_2_1;?>" type="text"> /
            <label for="element_2_1">MM</label>
        </span>
        <span>
            <input id="element_2_2" name="element_2_2" class="element text" size="2" maxlength="2" value="<?=$element_2_2;?>" type="text"> /
            <label for="element_2_2">DD</label>
        </span>
        <span>
             <input id="element_2_3" name="element_2_3" class="element text" size="4" maxlength="4" value="<?=$element_2_3;?>"type="text">
            <label for="element_2_3">YYYY</label>
        </span>
    
        <span id="calendar_2">
            <img id="cal_img_2" class="datepicker" src="../images/calendar.gif" alt="calendar">    
        </span>
        <script type="text/javascript">
            Calendar.setup({
            inputField     : "element_2_3",
            baseField    : "element_2",
            displayArea  : "calendar_2",
            button         : "cal_img_2",
            ifFormat     : "%B %e, %Y",
            onSelect     : selectDate
            });
        </script>
         </td></tr>
         
         <tr><td> <label>End Date: <span class="required">*</span> </label></td><td>
                <span>
            <input id="element_3_1" name="element_3_1" class="element text" size="2" maxlength="2" value="<?=$element_3_1;?>" type="text"> /
            <label for="element_3_1">MM</label>
        </span>
        <span>
            <input id="element_3_2" name="element_3_2" class="element text" size="2" maxlength="2" value="<?=$element_3_2;?>" type="text"> /
            <label for="element_3_2">DD</label>
        </span>
        <span>
             <input id="element_3_3" name="element_3_3" class="element text" size="4" maxlength="4" value="<?=$element_3_3;?>" type="text">
            <label for="element_3_3">YYYY</label>
        </span>
    
        <span id="calendar_3">
            <img id="cal_img_3" class="datepicker" src="../images/calendar.gif" alt="calendar">    
        </span>
        <script type="text/javascript">
            Calendar.setup({
            inputField     : "element_3_3",
            baseField    : "element_3",
            displayArea  : "calendar_3",
            button         : "cal_img_3",
            ifFormat     : "%B %e, %Y",
            onSelect     : selectDate
            });
        </script>
         </td></tr>
                        
                 <tr><td class="setwidth"><label>Reason for Leaving: <span class="required">*</span> </label></td>
                        <td><input name="reason" type="text" class="box" id="reason" size="30" value="<?=$reason;?>" /></td></tr>
     
                 <tr><td class="setwidth"><label>May we contact this employer? <span class="required">*</span></label></td>
<td><input type="radio" name="contact" value="Yes">Yes
<input type="radio" name="contact" value="No">No </td></tr>     
                                                 <tr><td>&nbsp;</td></tr> 
             <tr><td style="border-top: thin #ccc solid;" colspan="2">&nbsp;</td></tr> 
               <tr><td class="setwidth"><label>Company Name: </label></td>
                        <td><input name="company2" type="text" class="box" id="company2" size="30" value="<?=$company2;?>" /></td></tr> 
               
              <tr><td class="setwidth"><label>Phone Number:</label></td>
                 <td>
            <input id="workphone4" name="workphone4" size="3" maxlength="3" type="text" value="<?=$workphone4;?>"> -        
        
            <input id="workphone5" name="workphone5" size="3" maxlength="3" type="text" value="<?=$workphone5;?>"> -        

            <input id="workphone6" name="workphone6" size="4" maxlength="4" type="text" value="<?=$workphone6;?>">        

    </td></tr> 
                        
                   <tr><td class="setwidth"><label>City/Town:</label></td>
                        <td><input name="workcity2" type="text" class="box" id="workcity2" size="30" value="<?=$workcity2;?>" /></td></tr> 
                        
                  <tr><td class="setwidth"><label>Province: </label></td>
                        <td>                      
<select name="workprov2" id="workprov2">                
        <?= select_options($workprov2, $_POST['workprov2']) ?>
                        </select>
                        </td></tr>    
                        
                 <tr><td class="setwidth"><label>Supervisor's Name: </label></td>
                        <td><input name="supervisor2" type="text" class="box" id="supervisor2" size="30" value="<?=$supervisor2;?>" /></td></tr> 
                  
                  <tr><td valign="top" class="setwidth"><label>Description of Job Duties and Responsibilities:</label></td>
                     <td><textarea name="job2" cols="30" rows="6"  id="job2"><?=$job2;?></textarea></td></tr>
                        
               <tr><td> <label>Start Date: </label></td><td>
<span>
            <input id="element_4_1" name="element_4_1" class="element text" size="2" maxlength="2" value="<?=$element_4_1;?>" type="text"> /
            <label for="element_4_1">MM</label>
        </span>
        <span>
            <input id="element_4_2" name="element_4_2" class="element text" size="2" maxlength="2" value="<?=$element_4_2;?>" type="text"> /
            <label for="element_4_2">DD</label>
        </span>
        <span>
             <input id="element_4_3" name="element_4_3" class="element text" size="4" maxlength="4"value="<?=$element_4_3;?>" type="text">
            <label for="element_4_3">YYYY</label>
        </span>
    
        <span id="calendar_4">
            <img id="cal_img_4" class="datepicker" src="calendar.gif" alt="calendar">    
        </span>
        <script type="text/javascript">
            Calendar.setup({
            inputField     : "element_4_3",
            baseField    : "element_4",
            displayArea  : "calendar_4",
            button         : "cal_img_4",
            ifFormat     : "%B %e, %Y",
            onSelect     : selectDate
            });
        </script>
         </td></tr>
                                         
               <tr><td> <label>End Date:</label></td><td>
<span>
            <input id="element_5_1" name="element_5_1" class="element text" size="2" maxlength="2" value="<?=$element_5_1;?>" type="text"> /
            <label for="element_5_1">MM</label>
        </span>
        <span>
            <input id="element_5_2" name="element_5_2" class="element text" size="2" maxlength="2" value="<?=$element_5_2;?>" type="text"> /
            <label for="element_5_2">DD</label>
        </span>
        <span>
             <input id="element_5_3" name="element_5_3" class="element text" size="4" maxlength="4" value="<?=$element_5_3;?>" type="text">
            <label for="element_5_3">YYYY</label>
        </span>
    
        <span id="calendar_5">
            <img id="cal_img_5" class="datepicker" src="calendar.gif" alt="calendar">    
        </span>
        <script type="text/javascript">
            Calendar.setup({
            inputField     : "element_5_3",
            baseField    : "element_5",
            displayArea  : "calendar_5",
            button         : "cal_img_5",
            ifFormat     : "%B %e, %Y",
            onSelect     : selectDate
            });
        </script>
         </td></tr>
         
                 <tr><td class="setwidth"><label>Reason for Leaving:</label></td>
                        <td><input name="reason2" type="text" class="box" id="reason2" size="30" value="<?=$reason2;?>" /></td></tr>
     
                 <tr><td class="setwidth"><label>May we contact this employer?</label></td>
<td><input type="radio" name="contact2" value="Yes">Yes
<input type="radio" name="contact2" value="No">No </td></tr>    
                        
                                                 <tr><td>&nbsp;</td></tr> 
             <tr><td style="border-top: thin #ccc solid;" colspan="2">&nbsp;</td></tr> 

               <tr><td class="setwidth"><label>Company Name: </label></td>
                        <td><input name="company3" type="text" class="box" id="company3" size="30" value="<?=$company3;?>" /></td></tr> 
               
              <tr><td class="setwidth"><label>Phone Number: </label></td>
                 <td>
            <input id="workphone7" name="workphone7" size="3" maxlength="3" type="text" value="<?=$workphone7;?>"> -        
        
            <input id="workphone8" name="workphone8" size="3" maxlength="3"type="text" value="<?=$workphone8;?>"> -        

            <input id="workphone9" name="workphone9" size="4" maxlength="4" type="text" value="<?=$workphone9;?>">        

    </td></tr>  
                        
                   <tr><td class="setwidth"><label>City/Town:</label></td>
                        <td><input name="workcity3" type="text" class="box" id="workcity3" size="30" value="<?=$workcity3;?>" /></td></tr> 
                        
                  <tr><td class="setwidth"><label>Province: </label></td>
                        <td>                      
<select name="workprov3" id="workprov3">                
        <?= select_options($workprov3, $_POST['workprov3']) ?>
                        </select>
                        </td></tr>    
                        
                 <tr><td class="setwidth"><label>Supervisor's Name: </label></td>
                        <td><input name="supervisor3" type="text" class="box" id="supervisor3" size="30" value="<?=$supervisor3;?>" /></td></tr> 
                  
                  <tr><td valign="top" class="setwidth"><label>Description of Job Duties and Responsibilities:</label></td>
                     <td><textarea name="job3" cols="30" rows="6"  id="job3"><?=$job3;?></textarea></td></tr>
                        
               <tr><td> <label>Start Date:</label></td><td>
<span>
            <input id="element_6_1" name="element_6_1" class="element text" size="2" maxlength="2" value="<?=$element_6_1;?>" type="text"> /
            <label for="element_6_1">MM</label>
        </span>
        <span>
            <input id="element_6_2" name="element_6_2" class="element text" size="2" maxlength="2" value="<?=$element_6_2;?>" type="text"> /
            <label for="element_6_2">DD</label>
        </span>
        <span>
             <input id="element_6_3" name="element_6_3" class="element text" size="4" maxlength="4" value="<?=$element_6_3;?>" type="text">
            <label for="element_6_3">YYYY</label>
        </span>
    
        <span id="calendar_6">
            <img id="cal_img_6" class="datepicker" src="calendar.gif" alt="calendar">    
        </span>
        <script type="text/javascript">
            Calendar.setup({
            inputField     : "element_6_3",
            baseField    : "element_6",
            displayArea  : "calendar_6",
            button         : "cal_img_6",
            ifFormat     : "%B %e, %Y",
            onSelect     : selectDate
            });
        </script>         </td></tr>
                 
               <tr><td> <label>End Date:</label></td><td>
<span>
            <input id="element_7_1" name="element_7_1" class="element text" size="2" maxlength="2" value="<?=$element_7_1;?>" type="text"> /
            <label for="element_7_1">MM</label>
        </span>
        <span>
            <input id="element_7_2" name="element_7_2" class="element text" size="2" maxlength="2" value="<?=$element_7_2;?>" type="text"> /
            <label for="element_7_2">DD</label>
        </span>
        <span>
             <input id="element_7_3" name="element_7_3" class="element text" size="4" maxlength="4" value="<?=$element_7_3;?>" type="text">
            <label for="element_7_3">YYYY</label>
        </span>
    
        <span id="calendar_7">
            <img id="cal_img_7" class="datepicker" src="calendar.gif" alt="calendar">    
        </span>
        <script type="text/javascript">
            Calendar.setup({
            inputField     : "element_7_3",
            baseField    : "element_7",
            displayArea  : "calendar_7",
            button         : "cal_img_7",
            ifFormat     : "%B %e, %Y",
            onSelect     : selectDate
            });
        </script>     </td></tr>
        
                 <tr><td class="setwidth"><label>Reason for Leaving:</label></td>
                        <td><input name="reason3" type="text" class="box" id="reason3" size="30" value="<?=$reason3;?>" /></td></tr>
     
                 <tr><td class="setwidth"><label>May we contact this employer?</label></td>
<td><input type="radio" name="contact3" value="Yes">Yes
<input type="radio" name="contact3" value="No">No </td></tr>    
                                                 <tr><td>&nbsp;</td></tr> 
             <tr><td style="border-top: thin #ccc solid;" colspan="2">&nbsp;</td></tr> 
             
 <tr><td valign="top" class="setwidth"><label>Please list any additional comments or details you would like us to consider while reviewing your application.</label></td>
                     <td><textarea name="comment" cols="30" rows="6"  id="comment"><?=$comment;?></textarea></td></tr>
                       

                           <tr><td class="setwidth"><label>Please read the our <a href="http://www.envirotec.ca/beta/company/privacy.php">Privacy Policy</a> carefully. <span class="required">*</span></label></td>
<td><input type="radio" name="accept" value="Yes">I accept
<input type="radio" name="accept" value="No">I do not accept </td></tr>    


                                                 <tr><td class="setwidth"><label>Spam Check: <span class="required">*</span> <b>2 + 3=</b></label></td>
                        <td><input name="spamcheck" type="text" class="box" id="spamcheck" size="4" value="<?=$spamcheck;?>" /></td></tr>
<tr><td>&nbsp;</td></tr>
                        <!-- Submit Button. Do not edit-->
                <tr><td> <input name="send" type="submit" class="button" id="send" value="Submit" /></td></tr>
            </form>
            </table>










----- CODE THAT WORKS

<html>
<head>
<title>Send an Email</title>
</head>
<body>
<?
$to="myemail@hotmail.com";
$subject="CFP Tyres Website: Claim Report Submission";
$from=stripslashes($_POST['Name'])."<".stripslashes($_POST['E-Mail_Address']).">";
$message="test message";
 
$mime_boundary="==Multipart_Boundary_x".md5(mt_rand())."x";
 
$headers = "From: $from\r\n" .
"MIME-Version: 1.0\r\n" .
"Content-Type: multipart/mixed;\r\n" .
" boundary=\"{$mime_boundary}\"";
 
$message = "This is a multi-part message in MIME format.\n\n" .
"--{$mime_boundary}\n" .
"Content-Type: text/plain; charset=\"iso-8859-1\"\n" .
"Content-Transfer-Encoding: 7bit\n\n" .
$message . "\n\n";
 
foreach($_FILES as $userfile) {
        $fileatt = $userfile['tmp_name'];
        $fileatt_type = $userfile['type'];
        $fileatt_name = $userfile['name'];
 
        if (file_exists($fileatt)){
                if(is_uploaded_file($fileatt)){
                        $file = fopen($fileatt,'rb');
                        $data = fread($file,filesize($fileatt));
                        fclose($file);
                        $data = chunk_split(base64_encode($data));
                }
                $message .= "--{$mime_boundary}\n" .
                "Content-Type: {$fileatt_type};\n" .
                " name=\"{$fileatt_name}\"\n" .
                "Content-Disposition: attachment;\n" .
                " filename=\"{$fileatt_name}\"\n" .
                "Content-Transfer-Encoding: base64\n\n" .
                $data . "\n\n";
        }
}
 
$message.="--{$mime_boundary}--\n";
 
if (@mail($to, $subject, $message, $headers))
        echo "success";
else
        echo "error";

?>

<form method="POST" action="" enctype="multipart/form-data"> 
Enter Name: <input type="text" name="name"><br> 
Enter Message: <textarea name="message"></textarea><br>
Select A File To Upload: <input type="file" name="fileatt"><br>
Select A File To Upload: <input type="file" name="fileatt2"><br>
<input type="submit" value="Submit"><br>
</form>
</body>
</html>

Open in new window

Comment
Watch Question
This problem has been solved!
Unlock 1 Answer and 7 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE