Jump to content

PHP Mail (Multiple Files)


sblake161189

Recommended Posts

Hi Guys,

 

I have a HTML form which posts to a PHP mail script page. This data then emails to the company email address.

 

I have two file attachments on my form: CV and Photo ID

 

How do I integrate my php mail script to upload and then email these TWO files as TWO attachements on the email?

 

$fileatt_cv

$fileatt_id

 

I have tried a few methods that I found on Google but they dont work  :(

 

<?php

// Grab Data from Form
if(isset($_POST['submit'])) {

// Personal Information
$surname = mysql_real_escape_string($_POST['surname']);
$firstname = mysql_real_escape_string($_POST['firstname']);
$telephone = mysql_real_escape_string($_POST['telephone']);
$mobile = mysql_real_escape_string($_POST['mobile']);
$email = mysql_real_escape_string($_POST['email']);
$address = mysql_real_escape_string($_POST['address']);
$postcodep1 = mysql_real_escape_string($_POST['postcodep1']);
$postcodep2 = mysql_real_escape_string($_POST['postcodep2']);
$dob_dd = mysql_real_escape_string($_POST['dob_dd']);
$dob_mm = mysql_real_escape_string($_POST['dob_mm']);
$dob_yyyy = mysql_real_escape_string($_POST['dob_yyyy']);

// Next of Kin
$nextkinname = mysql_real_escape_string($_POST['nextkinname']);
$nextkintel = mysql_real_escape_string($_POST['nextkintel']);

// Availability
$days_mon = mysql_real_escape_string($_POST['days_mon']);
$days_tue = mysql_real_escape_string($_POST['days_tue']);
$days_wed = mysql_real_escape_string($_POST['days_wed']);
$days_thu = mysql_real_escape_string($_POST['days_thu']);
$days_fri = mysql_real_escape_string($_POST['days_fri']);
$days_sat = mysql_real_escape_string($_POST['days_sat']);
$days_sun = mysql_real_escape_string($_POST['days_sun']);
$availability_am = mysql_real_escape_string($_POST['availability_am']);
$availability_pm = mysql_real_escape_string($_POST['availability_pm']);
$availability_allday = mysql_real_escape_string($_POST['availability_allday']);
$availability_requirements = mysql_real_escape_string($_POST['availability_requirements']);

// Experience
$experience = mysql_real_escape_string($_POST['experience']);

// File Attachments
$fileatt_cv = mysql_real_escape_string($_POST['fileatt_cv']);
$fileatt_id = mysql_real_escape_string($_POST['fileatt_id']);

// Rates
$rate = mysql_real_escape_string($_POST['rate']);
$rate_specific = mysql_real_escape_string($_POST['rate_specific']);

// Employer Ref
$employrefname = mysql_real_escape_string($_POST['employrefname']);
$employrefcomp = mysql_real_escape_string($_POST['employrefcomp']);
$employreftel = mysql_real_escape_string($_POST['employreftel']);
$employrefadd = mysql_real_escape_string($_POST['employrefadd']);

// Personal Ref
$persrefname = mysql_real_escape_string($_POST['persrefname']);
$persreftel = mysql_real_escape_string($_POST['persreftel']);
$persrefadd = mysql_real_escape_string($_POST['persrefadd']);

// Extra Information
$allergy = mysql_real_escape_string($_POST['allergy']);
$allergy_details = mysql_real_escape_string($_POST['allergy_details']);
$drive = mysql_real_escape_string($_POST['drive']);
$car = mysql_real_escape_string($_POST['car']);
$criminal = mysql_real_escape_string($_POST['criminal']);
$criminal_details = mysql_real_escape_string($_POST['criminal_details']);
$howlongworkuk = mysql_real_escape_string($_POST['howlongworkuk']);
$police_check = mysql_real_escape_string($_POST['police_check']);
$right2work = mysql_real_escape_string($_POST['right2work']);
$right2workna = mysql_real_escape_string($_POST['right2workna']);


// Email Options
$subject = "Test Company - Job Application";
$to = "test@test.com"; 
$mailheader = "From: $email" . "\r\n";
$mailheader .= 'MIME-Version: 1.0' . "\r\n";
$mailheader .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

// Applicants copy
$mailheader .= "BCc: $email" . "\r\n";

// Message Content

$body .= 'Message';


// End of Email Content > Display Message

echo "Thank you. Your application was submitted to us successly. We review all applications carefully and we may contact you shortly.";

// Attempt to Send Email

mail($to, $subject, $body, $mailheader);

} else {

echo "Application Failed. Unfortunatley, there was a problem with your application and it was not submitted. Please try again later or alternativley please contact us.";

}
?>

 

Thanks in advanced.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.