<?

$mailto = 'toomas@kuidas.ee' ;

$subject = "Feedback" ;

$formurl = "http://www.ammattirakentaja.fi/nav_top/kilpailu/kilpailu.htm" ;
$errorurl = "http://www.ammattirakentaja.fi/nav_top/kilpailu/kilpailu.htm" ;
$thankyouurl = "http://www.ammattirakentaja.fi/dsm_test/feedback/thankyou.php" ;

$uself = 0;


$headersep = (!isset( $uself ) || ($uself == 0)) ? "\r\n" : "\n" ;
$name = $_POST['name'] ;
$email = $_POST['email'] ;
$employment = $_POST['employment'] ;
$company = $_POST['company'] ;
$address = $_POST['address'] ;
$comments_a = $_POST['comments_a'] ;
$comments_b = $_POST['comments_b'] ;
$comments_c = $_POST['comments_c'] ;
$http_referrer = getenv( "HTTP_REFERER" );

if (!isset($_POST['email'])) {
	header( "Location: $formurl" );
	exit ;
}
if (empty($name) || empty($email) || empty($comments_a) || empty($comments_b) || empty($comments_c)) {
   header( "Location: $errorurl" );
   exit ;
}
if ( ereg( "[\r\n]", $name ) || ereg( "[\r\n]", $email ) ) {
	header( "Location: $errorurl" );
	exit ;
}

if (get_magic_quotes_gpc()) {
	$comments_a = stripslashes( $comments_a );
	$comments_b = stripslashes( $comments_b );
	$comments_c = stripslashes( $comments_c );
}

$messageproper =

	"This message was sent from:\n" .
	"$http_referrer\n" .
	"------------------------------------------------------------\n" .
	"Name of sender: $name\n" .
	"Email of sender: $email\n" .
	"Sender works in $company as $employment\n" .
	"Sender's address is: $address\n" .
	"------------------------- Kilpailu -------------------------\n\n" .
	"1.Mitä mieltä oled Ammattirakentajan ulkosusta?\n" .
	$comments_a .
	"\n\n2.Onko lehdessä liikää mainoksia?\n" .
	$comments_b .
	"\n\n3.Mitä haluasit lehteen lisää?\n" .
	$comments_c .
	"\n\n------------------------------------------------------------\n" ;

mail($mailto, $subject, $messageproper,
	"From: \"$name\" <$email>" . $headersep . "Reply-To: \"$name\" <$email>" . $headersep . "X-Mailer: chfeedback.php 2.07" );
header( "Location: $thankyouurl" );
exit ;

?>
