Location: PHPKode > projects > HuMo-gen > mailform.php
<?php
$kop="adreslink";
include("header.php");
include ("menu.php");

// *** Extra: change this value to "true" if you want the question "newsletter" added in the mailform. ***
$newsletter_question=false;

if (isset($_POST['verstuur'])){
	$adres=$dataDb->tree_email;

	$onderwerp="HuMo-gen ".$language["mail_mailform_short"]." (".database_name($_SESSION['tree_prefix'], $Taalkeuze)."): ".$_POST['onderwerp']."\n";

	// *** It's better to use plain text in the subject ***
	$onderwerp=strip_tags($onderwerp,ENT_QUOTES);

	$bericht =$language["mail_message_sent"]."<br>\n";
	$bericht .="<br>\n";
	$bericht .=$language["mail_name"].$_POST['naam']."<br>\n";
	$bericht .=$language["mail_email"].$_POST['afzender']."<br>\n";
	if (isset($_SESSION['save_last_visitid'])){
		$bericht.=$language["mail_last_family"].' '.$_SESSION['save_last_visitid']."<br>\n";
	}
	if ($newsletter_question){
		$bericht.=$language["mail_newsletter"].' '.$_POST['newsletter']."<br>\n";
	}
	$bericht .=$_POST['tekst']."<br>\n";

	$headers  = "MIME-Version: 1.0\n";
	//$headers .= "Content-type: text/plain; charset=utf-8\n";
	$headers .= "Content-type: text/html; charset=utf-8\n";
	$headers .= "X-Priority: 3\n";
	$headers .= "X-MSMail-Priority: Normal\n";
	$headers .= "X-Mailer: php\n";
	$headers .= "From: \"".$_POST['naam']."\" <".$_POST['afzender'].">\n";

	echo '<br>'.$language["mail_mail_address_entered"].'<b> '.$_POST['afzender'].'</b><br>';
	$positie = strpos($_POST['afzender'],"@");
	if ($positie<1){ echo '<font color="red">'.$language["mail_no_valid_address"].'</font><br>'; }
	echo '<b>'.$language["mail_no_valid_address_answer"].'</b><br>';
	echo $language["mail_message"].'<br>'.$_POST['tekst'];

	@$mail = mail($adres, $onderwerp, $bericht, $headers);
	//return ($mail);
	if($mail){
		echo("<br>".$language["mail_email_sent"]);
	}
	else{
		echo "<br><b>".$language["mail_email_failed"]."</b><br>";
	}

}
else{

	if ($dataDb->tree_email){
		// print '<br><form method="post" action="'.$_SERVER['PHP_SELF'].'">';
		print '<br><form method="post" action="'.$_SERVER['PHP_SELF'].'" accept-charset = "utf-8">';
		print '<table align="center" class="humo rand">';
		print '<tr><td></td><th class="fonts">'.$language["mail_mailform_short"].'</th></tr>';
		print '<tr><td>'.$language["mail_name"].'</td><td><INPUT type="text" class="fonts" name="naam" size="40" style="background-color:#FFFFFF"></td></tr>';
		print '<tr><td>'.$language["mail_full_address"].'</td><td><INPUT type="text" class="fonts" name="afzender" value="'.$language["mail_example"].
		'" size="40" style="background-color:#FFFFFF"> '.$language["mail_reactions"].'</td></tr>';
		
		print '<tr><td>'.$language["source_subject"].'</td><td><INPUT type="text" class="fonts" name="onderwerp" size="80" style="background-color:#FFFFFF"></td></tr>';
		print '<tr><td>'.$language["mail_message"].'</td><td><TEXTAREA NAME="tekst" ROWS="10" COLS="40" class="fonts"></TEXTAREA></td></tr>';

		if ($newsletter_question){
			print '<tr><td>Nieuwsbrief ontvangen?</td><td>
			<input type="radio" name="newsletter" value="Yes"> Ja<br>
			<input type="radio" name="newsletter" value="No" checked> Nee</td></tr>';
		}

		print '<tr><td></td><th class="fonts" align="left">'.$language["mail_full_valid_address"].'</th></tr>';
		print '<tr><td></td><td><input class="fonts" type="submit" name="verstuur" value="'.$language["mail_send"].'"></td></tr>';
		print '</table>';
		print '</form>';
	}
	else{
		echo '<h2>'.$language["mail_switched_off"].'</h2>';
	}
}
include("footer.php");
?>
Return current item: HuMo-gen