<?php
	session_start();
	include('database.php');
	DB_connexion(); 
	
	$champ_nom = "";
	$champ_prenom = "";
	$champ_email = "";
	$champ_sujet = "";
	$champ_message = "";
	
	if(!empty($_POST["nom"]))
	{	$champ_nom = $_POST["nom"];
	}
	if(!empty($_POST["prenom"]))
	{	$champ_prenom = $_POST["prenom"];
	}
	if(!empty($_POST["email"]))
	{	$champ_email = $_POST["email"];
	}
	if(!empty($_POST["sujet"]))
	{	$champ_sujet = $_POST["sujet"];
	}
	if(!empty($_POST["message_textarea"]))
	{	$champ_message = $_POST["message_textarea"];
	}

	if( isset($_POST['valide_form']) && $_POST['valide_form'] == "ok" )
	  {
	  
				$to  = $champ_email;

				$champ_message = stripslashes($champ_message) ;
				
				
				$table = explode("\n", $champ_message);
				$nbr = count($table);  
				$contenu = '';	
				
				for($i=0;$i < $nbr  ;$i++) 
					{	
						$contenu .= $table[$i]; 
						$contenu .= '<br/>';
					}
					
				// clé aléatoire de limite
				$boundary = md5(uniqid(microtime(), TRUE));	

				
				// Pour envoyer un mail HTML, l'en-tête Content-type doit être défini
				//$headers  = 'MIME-Version: 1.0' . "\r\n";
				//$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

				// En-têtes additionnels
				/*$headers .= 'To: Mary <mary@example.com>, Kelly <kelly@example.com>' . "\r\n";
				$headers .= 'From: Anniversaire <anniversaire@example.com>' . "\r\n";
				$headers .= 'Cc: anniversaire_archive@example.com' . "\r\n";
				$headers .= 'Bcc: anniversaire_verif@example.com' . "\r\n";*/
				
				$headers = "";
				$headers = "MIME-Version: 1.0" . "\n";
				$headers .= "Content-type:text/html;charset=utf-8" . "\n";
				$headers .='Content-Transfer-Encoding: 8bit' . "\n";
				$headers .='From: admin@analog-design.net' . "\n";
				$headers .='Reply-To: admin@analog-design.net';
				
				$headers .= 'Content-Type: multipart/mixed;boundary=' .$boundary . "\n";

				
				mail($to, $champ_sujet, $contenu, $headers);
  
				$_SESSION['message'] = "ok";
  
					
			
	}			
	 
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="Description" content="Site perso,cours,ouvrages" />
<meta name="Keywords" content="WEBSITE perso " />
<meta name="Distribution" content="Global" />
<meta name="Robots" content="" />
<meta http-equiv="Content-Language" content="fr" />
<meta name="rating" content="general" />
<meta name="author" content="Patrice DELPY" />
<meta name="copyright" content="Copyright 2013" />
<meta name="generator" content="Patoche" />
<title>Patoche WEBSITE - 2013 - Template du site - en cours de développemment ...</title>
<!---------------------------------------------------------->	
<?php
		include('include_css_template_commun.php');
		include('include_css.php');
		include('css_tools_skill.php');
		include('include_javascript.php');

?> 

<style type="text/css">
</style>

<!---------------------------------------------------------->	
</head>

<body>
<!---------------------------------------------------------->	
	<div class="main"> <!-- main -->
<!---------------------------------------------------------->	

          <div class="header">
                <div class="balise_titre">Patoche</div>
                <div class="balise_citation">
                &quot;Etre conscient que l'on est ignorant est un grand pas vers le savoir&quot;
                </div>
          </div> 
 
          <div class="banniere"></div>  

<!---------------------------------------------------------->
<?php
/*	include("include_barre_login.php");
	echo '<div id="box_icon">';
	include("debug_connexion_membre.php");
	echo '</div>';
	include("include_menu.php");*/
	
	echo '<div id="box_infos">';
			include("include_menu.php");
			
			echo '<div id="box_icon2">';
			include("connexion_membre.php");
			echo	'</div>';
			
			echo '<div id="box_icon3">';
			include("include_barre_login.php");
			echo	'</div>';

	echo	'</div>';
	$_SESSION['page_active'] = basename (__FILE__ );
?>

		

<!---------------------------------------------------------->	
            <div class="contenu"> <!-- contenu -->
<!---------------------------------------------------------->	
					
				<div id="container_mail">
			
				<form method="post" id="form_email" action="contact.php" onsubmit="return envoyer_email(this)">
			 
				<h1>Formulaire Email:</h1>
				
				<input type="hidden" name="valide_form" id="valide_form" value="" />
				
				<div>
					<label for="nom">Nom</label>
					<input id="nom" name="nom" type="text" onKeyUp="verif_mot(this.value, 'statut_nom')" value = "<?php echo $champ_nom; ?>"  />
					<span id="statut_nom"></span>
				</div>
			
				<div>
					<label for="prenom">Prénom</label>
					<input id="prenom" name="prenom" type="text" onKeyUp="verif_mot(this.value, 'statut_prenom')" value = "<?php echo $champ_prenom; ?>"  />
					<span id="statut_prenom"></span>
				</div>
			
				<div>
					<label for="email">E-mail</label>
					<input id="email" name="email" type="text" onKeyUp="valide_email(this.value)" value = "<?php echo $champ_email; ?>" />
					<span id="statut_email"></span>
				</div>
			    
				<div>
					<label for="email">Sujet</label>
					<input id="sujet" name="sujet" type="text" onKeyUp="verif_mot(this.value)" value = "<?php echo $champ_sujet; ?>" />
					<span id="statut_sujet"></span>
				</div>
				
				<div>
					<label for="message">Message (10 lettres minimum)</label> 
					<textarea rows="4" cols="20" name="message_textarea" id="message_textarea" onKeyUp="verif_message(this.value)"><?php echo $champ_message; ?></textarea> 
				    <span id="statut_message"></span>
				</div>
				
				<div>
					<input id="send" name="send" type="submit" value="Envoyer" />
				</div>
				
<?php
				if($_SESSION['message'] == "ok")
				{	echo '<div id="message_traitement" style="display:block">Votre email vient d\'etre envoyé.</div>';
					$_SESSION['message'] = "none";
				}
?>		
				
				</form>
				</div>
				
<!---------------------------------------------------------->	
<?php			
            include('include_pied_page.php');
			include('include_publicite.php');
?>
<!---------------------------------------------------------->	
			</div>  <!-- contenu -->
<!---------------------------------------------------------->	
	</div>   <!-- main -->
<!---------------------------------------------------------->	

</body>
</html>
