Hello,
I am no php expert - in fact I know almost nothing about it! A friend of mine created a php script to process an HTML email form that I had made for a site. I am now working on another site and have managed to understand the php enough to adapt it for the new form (although it is essentially very similar, so I'm not as clever as I make out!)
Everything is going swimmingly, but my client now wants customers to be able to attach a photo to the email. I have no idea what to do and since my friend is a very busy person, I thought I would ask one of you kind people to help me out.
Below is a copy of the php form handling script as it stands (personal and website details removed):
<?
if ($name != "" && $email != "" && $phone != ""){
if ($enquiry !=""){ $enquiry = stripslashes($enquiry); }
// MAKING THE EMAIL AND SENDING IT
// EMAIL TO BE SENT TO...
$mail_to = "email@address.com";
// EMAIL SUBJECT
$mail_subject = "Enquiry sent from www.website.com";
// PROCESSING ADDRESS
if ($address1 != "" || $address2 != "" || $town != "" || $county != "" || $post_code!= ""){
$address = "\n - Address: \n";
}
if ($address1 != "" && $address2 == ""){
$address = $address . "\t" . $address1 . "\n";
} elseif ($address1 != "" && $address2 != ""){
$address = $address . "\t" . $address1 . "\n" . "\t" . $address2 . "\n";
} elseif ($address1 == "" && $address2 != ""){
$address = $address . "\t" . $address2 . "\n";
}
if ($town != ""){
$town = "\t" . $town . "\n";
}
if ($county != ""){
$county = "\t" . $county . "\n";
}
if ($post_code != ""){
$post_code = "\t" . $post_code . "\n";
}
// PROCESSING INTEREST
switch ($interest){
case "paint_restoration":
$interest = "is interested in paint restoration.";
break;
case "full_respray":
$interest = "is interested in full respray.";
break;
case "smart_repairs":
$interest = "is interested in smart repairs.";
break;
case "paintless_dent_removal":
$interest = "is interested in paintless dent removal.";
break;
case "insurance_work":
$interest = "is interested in insurance work.";
break;
case "":
$interest = "did not indicate any specific interest.";
break;
}
// PROCESSING ENQUIRY
if ($enquiry != ""){
$enquiry = "The following enquiry/comment was added:\n\n" . $enquiry;
}
// CREATING EMAIL CONTENT
$mail_body = "
Hello 🙂\n
-------------------------------------------------------------------------------------------\n
Sender's details:\n
- Name: $name
- Email: $email
- Phone: $phone
$address$town$county$post_code
-------------------------------------------------------------------------------------------\n
$name $interest \n
$prefer \n
-------------------------------------------------------------------------------------------\n
$enquiry";
// SENDING EMAILS
mail($mail_to, $mail_subject, $mail_body, $mail_from);
// THANK YOU MESSAGE AND REDIRECT
echo "<h4 style=\"font-family: Arial\">Thank you. Your enquiry has been sent.</h4>\n
<h5 style=\"font-family: Arial\">Click <a href=\"http://www.website.com\">here</a> if you're not being automatically redirected.</h5>\n
<script>
function redirect() {
window.location.replace(\"http://website.com/page_thanks.html\");
}
setTimeout(\"redirect();\", 10);
</script>
";
}elseif ($name == "" || $email == "" || $phone == ""){ //NO MESSAGE WAS WRITTEN
echo "<h4 style=\"font-family: Arial\">Sorry, you forgot to include your name, email address and phone number. Your query has not been sent. Please go back and complete the form again, ensuring that you include any required fields.</h4>\n
<h5 style=\"font-family: Arial\">Click <a href=\contact.html\">here</a> if you're not redirected to our contact us page.</h5>\n
<script>
function redirect() {
window.location.replace(\"Details.html\");
}
setTimeout(\"redirect();\", 8000);
</script>
";
}
?>
What would I need to add to this in order to enable the customer to attach an image? What changes would I need to make to the html too?
Any advice would be greatly appreciated.