This is the php code I have used-
Code: Select all
<?php
$to = "myemailaddress@hotmail.co.uk";
$phone = $_POST['phone'];
$name = $_POST['name'];
$subject = $_POST['subject'];
$address = $_POST['address'];
$message = $_POST['message'];
$fileatt = $_FILES['fileatt']['tmp_name'];
$fileatt_type = $_FILES['fileatt']['type'];
$fileatt_name = $_FILES['fileatt']['name'];
$headers = "From: $from";
if (is_uploaded_file($fileatt,'rb');
$file = fopen($fileatt,'rb');
$data = fread($file,filesize($fileatt));
fclose($file);
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
$headers .= "\nMIME-Version: 1.0\n" .
"Content-Type: multipart/mixed;\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";
$data = chunk_split(base64_encode($data));
// Add file attachment to the message
$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" .
"--{$mime_boundary}--\n";
}
$ok = ($phone, $subject, $message, $name, $address, $headers);
if ($ok) {
echo "<p>Thankyou your mail has been sent</p>";
else {
echo "<p>Mail could not be sent. Sorry!</p>";
}
?>
my html code is-
<html>
<head>
<title>Contact</title>
</head>
<body>
<h1>contact</h1>
<form action="mail.php" method="POST" enctype="multipart/form-data">
<p>Name: <input type="text" name="Name" value="" /><br />
Telephone: <input type="text" name="telephone" value="" /><br />
Subject: <input type="text" name="subject" value="" /><br/>
Address: <input type="text" name="address" value="" /></p>
<p>Message:<br />
<textarea cols="20" rows="10" name="message"></textarea></p>
<p>File Attachment: <input type="file" name="fileatt" /></p>
<p><input type="submit" value="Send" /></p>
</form>
</body>
</html>
Parse error: syntax error, unexpected ',' in E:\domains\m\my website address\user\htdocs\mail.php on line 60
I cannot figure out my mistake, so any help and ideas would be much appreciated.
Thankyou in advance for all your help.
Moe.