upload images

the mail() function

Moderators: egami, macek, gesf

Post Reply
User avatar
New php-forum User
New php-forum User
Posts: 8
Joined: Sat Jan 07, 2012 12:04 pm
Location: London

Fri May 04, 2012 7:46 pm

Hey guys, Iv created a form to allow users to sign a sort of membership form whereby they can input relevant details and there is an upload image option.

I have coded file both in HTML and PHP but I'm not sure how to go about adding the PHP code to send the image file to the email as an attachement or something.

here is a copy of the code: (e-mail has been removed)

Code: Select all

/* Subject and Email Variables */

	$emailSubject = 'New Member';
	$webMaster = 'email@address.com';
/* Gathering Data Variables */

	$firstname = $_POST['firstname'];
	$surname = $_POST['Surname'];
	$day = $_POST['DateOfBirth_Day'];
	$month = $_POST['DateOfBirth_Month'];
	$year = $_POST['DateOfBirth_Year'];
	$sex = $_POST['sex'];
	$email = $_POST['email'];
	$profession = $_POST['profession'];
	$body = <<<EOD
<strong>First Name:</strong><br> $firstname <br><br>
<strong>Surname:</strong><br> $surname <br><br>
<strong>D.O.B:</strong><br> $day - $month - $year <br><br>
<strong>Sex:</strong><br> $sex <br><br>
<strong>Email:</strong><br> $email <br><br>
<strong>Profession:</strong><br> $profession <br><br>

	$headers = "From: $email\r\n";
	$headers .= "Content-type: text/html\r\n";
	$success = mail($webMaster, $emailSubject, $body, $headers);
/* Results rendered as HTML */

$theResults = <<<EOD
<!DOCTYPE html>
<html lang="en">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 
<title>Message Sent!</title>
<meta http-equiv="refresh" content="5;URL=http://www.hardkase.co.uk/">
<style type="text/css">
	#text { width: 450px; margin: 100px auto 0 auto; }
	body { width: 100%;	height: 100%; background: black;}
	h1, h2 {color: white;}

<div id="text">
	<h1>Thank you for your application.</h1>
	<h2>Your request will be dealt with as soon as possible and you will be notified by e-mail once your application has been approved.</h2>

echo  $theResults;


User avatar
php-forum Active User
php-forum Active User
Posts: 277
Joined: Wed Aug 25, 2010 10:42 am

Mon May 07, 2012 12:57 am


try to use PHPMailer - http://phpmailer.worxware.com/

Post Reply