I have an HTML form that the user has to fill and upload 6 different files in either, JPG, JPEG, PNG or PDF format and I want when the user uploads the files individually, they'll send as an attachment to the designated email before they get a loan from the company how do I make the PHP code to send all six files as attachments to the designated email? Below is the code
HTML CODE
<form method="post" action="lib/data_form.php" id="contact-form" class="default-form" enctype="multipart/form-data">
<div class="row clearfix">
<div class="col-lg-6 col-md-6 col-sm-12 form-group">
<select class="form-select" name="company_structure" aria-label="Default select example">
<option selected>Company Structure</option>
<option value="Sole Proprietor">Sole Proprietor</option>
<option value="Partnership">Partnership</option>
<option value="C-Corp">C-Corp</option>
<option value="S-Corp">S-Corp</option>
<option value="LLC">LLC</option>
</select>
</div>
<div class="col-lg-6 col-md-6 col-sm-12 form-group">
<input type="text" name="dba_tradename" placeholder="DBA or Tradename (if applicable)" />
</div>
<div class="col-lg-6 col-md-6 col-sm-12 form-group">
<input type="text" name="year_of_est" placeholder="Year of Establishment" />
</div>
<div class="col-lg-6 col-md-6 col-sm-12 form-group">
<input type="text" name="business_legal_name" placeholder="Business Legal Name" />
</div>
<div class="col-lg-6 col-md-12 col-sm-12 form-group">
<input type="text" name="reg_no" placeholder="Registration Number" />
</div>
<div class="col-lg-6 col-md-6 col-sm-12 form-group">
<select class="form-select" name="company_size" aria-label="Default select example">
<option selected>Company Size (including affiliates, if applicable) meets size standard (select one)</option>
<option value="Less Than 50 Employees">Less Than 50 Employees</option>
<option value="50 Employees">50 Employees</option>
<option value="Above 50 Employees">Above 50 Employees</option>
</select>
</div>
<div class="col-lg-12 col-md-12 col-sm-12 form-group">
<textarea name="address" placeholder="Business Address (Street, City, State, Zip Code. No P.O. Box addresses allowed)"></textarea>
</div>
<div class="col-lg-6 col-md-12 col-sm-12 form-group">
<input type="text" name="business_status" placeholder="Business Status" />
</div>
<div class="col-lg-6 col-md-12 col-sm-12 form-group">
<input type="text" name="business_phone" placeholder="Business Phone" />
</div>
<div class="col-lg-6 col-md-12 col-sm-12 form-group">
<input type="text" name="primary_contact" placeholder="Primary Contact" />
</div>
<div class="col-lg-6 col-md-12 col-sm-12 form-group">
<input type="email" name="email" placeholder="Email Address" />
</div>
<div class="col-lg-6 col-md-12 col-sm-12 form-group">
<input type="text" name="principal_name" placeholder="Principal Name" />
</div>
<div class="col-lg-6 col-md-12 col-sm-12 form-group">
<input type="text" name="principal_position" placeholder="Principal Position" />
</div>
<div class="col-lg-6 col-md-6 col-sm-12 form-group">
<select class="form-select" name="gender" aria-label="Default select example">
<option selected>Gender</option>
<option value="Male">Male</option>
<option value="Female">Female</option>
<option value="Not Disclosed">Not Disclosed</option>
</select>
</div>
<div class="col-lg-6 col-md-6 col-sm-12 form-group">
<!-- <select class="selectpicker" multiple name="company_size" aria-label="Default select example">
<option>Type of Insurance (more than 1 may be selected)</option>
<option value="Health Insurance">Health Insurance</option>
<option value="Life Insurance">Life Insurance</option>
<option value="Property Insurance">Property Insurance</option>
<option value="Investment Liability Insurance">Investment Liability Insurance</option>
<option value="Guarantee Insurance">Guarantee Insurance</option>
<option value="Not Disclosed">Not Disclosed</option>
</select> -->
Type of Insurance
<div class="form-check">
<input class="form-check-input" name="insurance_type[]" value="Health Insurance" type="checkbox" value="" id="flexCheckDefault" required="">
<label class="form-check-label" for="flexCheckDefault">
Health Insurance
</label>
</div>
<div class="form-check">
<input class="form-check-input" name="insurance_type[]" value="Life Insurance" type="checkbox" value="" id="flexCheckDefault" required="">
<label class="form-check-label" for="flexCheckDefault">
Life Insurance
</label>
</div>
<div class="form-check">
<input class="form-check-input" name="insurance_type[]" value="Property Insurance" type="checkbox" value="" id="flexCheckDefault" required="">
<label class="form-check-label" for="flexCheckDefault">
Property Insurance
</label>
</div>
<div class="form-check">
<input class="form-check-input" name="insurance_type[]" value="Investment Liability Insurance" type="checkbox" value="" id="flexCheckDefault" required="">
<label class="form-check-label" for="flexCheckDefault">
Investment Liability Insurance
</label>
</div>
<div class="form-check">
<input class="form-check-input" name="insurance_type[]" value="Guarantee Insurance" type="checkbox" value="" id="flexCheckDefault" required="">
<label class="form-check-label" for="flexCheckDefault">
Guarantee Insurance
</label>
</div>
<div class="form-check">
<input class="form-check-input" name="insurance_type[]" value="Not Disclosed" type="checkbox" value="" id="flexCheckDefault" required="">
<label class="form-check-label" for="flexCheckDefault">
Not Disclosed
</label>
</div>
</div>
<div class="col-lg-6 col-md-12 col-sm-12 form-group">
<input type="file" name="certificate" placeholder="Certificate of Incorporation" />
</div>
<div class="col-lg-6 col-md-12 col-sm-12 form-group">
<input type="file" name="id_card" placeholder="Valid Identification Card" />
</div>
<div class="col-lg-6 col-md-12 col-sm-12 form-group">
<input type="file" name="executive_summary" placeholder="Executive Summary" />
</div>
<div class="col-lg-6 col-md-12 col-sm-12 form-group">
<input type="file" name="contract" placeholder="Signed Contract with Investor" />
</div>
<div class="col-lg-6 col-md-12 col-sm-12 form-group">
<input type="file" name="utility" placeholder="Most Recent Utility Bill" />
</div>
<div class="col-lg-6 col-md-12 col-sm-12 form-group">
<input type="file" name="statement" placeholder="Company Financial Statement" />
</div>
<!-- <div class="col-lg-12 col-md-12 col-sm-12 form-group">
<textarea name="message" placeholder="Your Message ..."></textarea>
</div> -->
<div class="col-lg-12 col-md-12 col-sm-12 form group mb-15">
<div class="form-check">
<input class="form-check-input" type="checkbox" value="" id="flexCheckDefault" required="">
<label class="form-check-label" for="flexCheckDefault">
By submitting the form, I confirm that the information is true to the best of my knowledge
</label>
</div>
</div>
<div class="col-lg-12 col-md-12 col-sm-12 form-group message-btn">
<button class="theme-btn-one" type="submit" name="submit-form">
Submit Now
</button>
</div>
</div>
</form>
PHP MAIL CODE
<?php
if(isset($_POST['submit-form'])) {
$company_structure = $_POST['company_structure'];
$dba_tradename = $_POST['dba_tradename'];
$year_of_est = $_POST['year_of_est'];
$business_legal_name = $_POST['business_legal_name'];
$reg_no = $_POST['reg_no'];
$company_size = $_POST['company_size'];
$address = $_POST['address'];
$business_status = $_POST['business_status'];
$business_phone = $_POST['business_phone'];
$primary_contact = $_POST['primary_contact'];
$email = $_POST['email'];
$principal_name = $_POST['principal_name'];
$principal_position = $_POST['principal_position'];
$gender = $_POST['gender'];
$insurance_type = $_POST['insurance_type'];
$insur_chk = "";
foreach ($insurance_type as $insur_chk1) {
$insur_chk .= $insur_chk1 . ",";
}
$subject = "Data Collection Form";
$to = "[email protected]";
$body = "You have received a data application form " .$name.
".\n\n Company Structure: " .$company_structure.
".\n\n DBA or Tradename: " .$dba_tradename.
".\n\n Year of Establishment: " .$year_of_est.
".\n\n Business Legal Name: " .$business_legal_name.
".\n\n Registration Number: " .$reg_no.
".\n\n Company Size: " .$company_size.
".\n\n Registration Number: " .$address.
".\n\n Registration Number: " .$business_status.
".\n\n Registration Number: " .$business_phone.
".\n\n Registration Number: " .$primary_contact.
".\n\n Registration Number: " .$email.
".\n\n Registration Number: " .$principal_name.
".\n\n Registration Number: " .$principal_position.
".\n\n Registration Number: " .$gender.
".\n\n Registration Number: " .$insur_chk;
//headers
$headers = "From: " .$email;
//send
$send = mail($to, $subject, $body, $headers);
if($send) {
echo("<script>alert('Thanks for submitting you data, we will get back to you shortly')</script>");
echo("<script>window.location = '../index.php';</script>");
}
else {
echo "Error in submitting form";
}
}
?>