Hi GURUS,
This php script works so I have done most of the hard work
I want to display my results as HTML text instead of PLAIN text
How can I make this possible?
<html>
<head>
<title> Sending Email </title>
</head>
<body>
<?php
// Read POST request params into global vars
$to = "xxx@xxx.com.au";
$from = $_POST['email'];
$subject = $_POST['subject'];
$message = stripslashes($_POST['enquiry']);
$yourdomain = "xxxx.com.au";
$YourWebsiteURL = "http://www.".$yourdomain."/";
$fromtest = strpos($from, $yourdomain);
//start building the mail string
$msg = "<h2><strong>The following results have been collected from the <br />xxxx Website Contact Form</strong></h2>";
$msg .= "<p><strong>Full Name:</strong> $_POST[name]</p>";
$msg .= "<p><strong>Job Seeker Number:</strong> $_POST[id]</p>";
$msg .= "<p><strong>Where are you from?</strong> $_POST[live]</p>";
$msg .= "<p><strong>Phone:</strong> $_POST[phone]</p>";
$msg .= "<p><strong>Email:</strong> $_POST[email]</p>";
$msg .= "<p><strong>Subject:</strong> $_POST[regions]</p>";
$msg .= "<p><strong>What regions are you interested in?</strong><br />1. $_POST[adelaide]<br />2. $_POST[berri]<br />3. $_POST[gawler]<br />4. $_POST[mtgambier]<br />5. $_POST[adelnw]<br />6. $_POST[adelne]<br />7. $_POST[ptlincoln]<br />8. $_POST[whyalla]</p>";
$msg .= "<p><strong>Enquiry:</strong> $_POST[enquiry]</p>";
// If they call this page direct from the browser, send them away because they havent filled in
// the form! Also, test to see if some joker is using my domain as their email addy
if($from == "" || $fromtest == true) {
header("location: $YourWebsiteURL");
exit();
}
// Obtain file upload vars
$fileatt = $_FILES['fileatt']['tmp_name'];
$fileatt_type = $_FILES['fileatt']['type'];
$fileatt_name = $_FILES['fileatt']['name'];
$headers = "From: $from";
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=ISO-8859-1\r\n";
if (is_uploaded_file($fileatt)) {
// Read the file to be attached ('rb' = read binary)
if (is_uploaded_file($fileatt)) {
$file = fopen($fileatt,'rb');
$data = fread($file,filesize($fileatt));
fclose($file);
// Base64 encode the file data
$data = chunk_split(base64_encode($data));
}
// Generate a boundary string
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
// Add the headers for a file attachment
$headers .= "\nMIME-Version: 1.0\n" .
"Content-Type: multipart/mixed;\n" .
" boundary=\"{$mime_boundary}\"";
// Add a multipart boundary above the plain message
$message = "This is a multi-part message in MIME format.\n\n" .
"--{$mime_boundary}\n" .
"Content-Type: text/html;\n charset=\"iso-8859-1\"\n" .
"Content-Transfer-Encoding: 7bit\n\n" .
$message . "\n\n" .
"--{$mime_boundary}\n";
// Add file attachment(s) to the message
if ($fileatt_name > "") {
$message .= "Content-Type: {$fileatt_type};\n" .
" name=\"{$fileatt_name}\"\n" .
"Content-Transfer-Encoding: base64\n" .
"Content-Disposition: attachment;\n" .
" filename=\"{$fileatt_name}\"\n\n" .
$data . "\n" .
"--{$mime_boundary}\n";
}
$message .= "--\n\n";
}
//Validate the email address used
if (eregi('^[a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+\.([a-zA-Z]{2,4})$', $from)) {
// Send the message
$ok = @mail($to, $subject, $message, $msg, $headers);
if ($ok) {
echo "<p>Mail sent! Yay PHP!</p>";
$fpl = fopen("log.txt","a");
fputs($fpl, date("d.M.Y h:m:s",time())." | ".$PATH_INFO." | ".$REMOTE_ADDR." |
".$REMOTE_HOST."<br>n");
fclose($fpl);
$url="http://www.xxxx.com.au/contact_thanks.html"; //insert your redirect locations here
}
} else {
echo "<p>Mail could not be sent. Sorry!</p>";
}
?>
<script language="javascript">
window.location.href=("<?php echo $url; ?>");
</script>
</body>
</html>