View Single Post
05-24-2008, 09:03 PM
#10
mason.sklut is offline mason.sklut
mason.sklut's Avatar
Status: Junior Member
Join date: Mar 2007
Location: North Carolina
Expertise: Photography
Software:
 
Posts: 73
iTrader: 0 / 0%
 

mason.sklut is on a distinguished road

  Old

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']);
		
?>