This is the code I used for the contact form....Any comments?
Code:
<?php
// Pick up the form data and assign it to variables
$name = $_POST['name'];
$email = $_POST['email'];
$topic = $_POST['url'];
$comments = $_POST['comments'];
// Build the email
$to = 'mason@masonsklut.com';
$subject = "New message: $topic";
$message = "$name said: $comments";
$headers = "E-mail: $email";
// Send the mail using PHPs mail() function
mail($to, $subject, $message, $headers);
// Redirect
header('Location: http://masonsklut.com/test/success.html');
// Mail header removal
function remove_headers($string) {
$headers = array(
"/to\:/i",
"/from\:/i",
"/bcc\:/i",
"/cc\:/i",
"/Content\-Transfer\-Encoding\:/i",
"/Content\-Type\:/i",
"/Mime\-Version\:/i"
);
$string = preg_replace($headers, '', $string);
return strip_tags($string);
}
// Pick up the cleaned form data
$name = remove_headers($_POST['name']);
$email = remove_headers($_POST['email']);
$topic = remove_headers($_POST['url']);
$comments = remove_headers($_POST['comment']);
?>