<?php

	 session_start();
	 
	 include('../config_inc.php'); 
	 
	 if($_SESSION['database']=="local")
	  {
	     $db_host    = "localhost";
	     $db_user   = "root";
	     $db_pass   = "";
     	     $db_name   = "boutique";

	 }
	
	if($_SESSION['database']=="public")
	  {
  	     $db_host    = "sql2";
   	     $db_user   = "analogde";
 	     $db_pass   = "rainbow";
    	     //$db_type   = "mysql";
	     $db_name   = "analogde";
	 }


    	    if(isset($_POST['valide']))
	      {
			  if($_POST['valide'] == "ok")
				{
					
				   /*if($_POST['valide_email'] == "non" )
				     { 	 echo '<body onLoad="alert(\'Email invalide.\')">'; 

				     }
				   
				   if($_POST['valide_identifiant']== "non" )	
				     { 	echo '<body onLoad="alert(\'Identifiant invalide.\')">'; 

				     }	*/
				   
				   if($_POST['valide_email'] == "ok" && $_POST['valide_identifiant']== "ok" )
				     {	
					
					$connexion = mysql_connect($db_host,$db_user,$db_pass); 
					mysql_select_db($db_name, $connexion);

					$email     = $_POST["email"] ;
					$identifiant     = $_POST["identifiant"] ;
					$password     = $_POST["password1"] ;
					$telephone     = $_POST["telephone"] ;

					$num_civilite     = $_POST["civ"] ;
					$nom     = $_POST["nom"] ;
					$prenom = $_POST["prenom"] ;
					$adr1 = $_POST["adr1"] ;
					$adr2 = $_POST["adr2"] ;
					$cp = $_POST["cp"] ;
					$ville = $_POST["ville"] ;
					
					$abonnement = $_POST['pub'];
					
					$jour = $_POST['jour'];
					$mois = $_POST['mois'];
					$annee = $_POST['annee'];
					
					$naissance = $jour ."-" .$mois ."-" .$annee;
										
					
					switch($num_civilite)
  					{
					  case 1 :
					          $civilite = "M";
					    	  break;
					  case 2 :
					          $civilite = "Mme";
					    	  break;		  
					  case 3 :
					          $civilite = "Mlle";
					    	  break;		  
					}
					
					$date = date("d-m-Y"); 
					$heure = date("H:i");
										
			       
  		$sql = "INSERT INTO clients( id, email, identifiant, password, telephone, civilite , nom, prenom, adresse,complement, cp, ville, date_inscription, heure, statut_compte, abonnement, age) 
   		VALUES('', '$email', '$identifiant', '$password' , '$telephone', '$civilite' , '$nom', '$prenom','$adr1','$adr2','$cp','$ville', '$date', '$heure', 'actif', '$abonnement', '$naissance')"; 
 
		$requete = mysql_query($sql);
		 
		// creation d'une entrée dans la table adresse_livraison : on initialise les valeurs
		 
		$sql = "INSERT INTO adresses_livraison( id, email, identifiant, titre1, nom1, prenom1, adresse1 , complement1, cp1, ville1,
 			titre2, nom2, prenom2, adresse2 , complement2, cp2, ville2 ) 
   			VALUES('', '$email', '$identifiant', '' , '', '' , '', '','','', '','', '', '', '', '' , '')"; 
		 
		 $requete = mysql_query($sql);
		 
		 // redirection dans la zone client
		 
		 //SELECT MAX(id) FROM clients;
		 //$mysql_result = mysql_query ("SELECT LAST_INSERT_ID()" );
		 //$row = mysql_fetch_row ($mysql_result);
		 //$id = $row[0]; 
		 
		 $_SESSION['email'] = $email;
		 $_SESSION['identifiant'] = $identifiant;
    		 $_SESSION['password'] = $password;
    		 $_SESSION['prenom'] = $prenom;
		 $_SESSION['id'] = $data["id"];
		 $_SESSION['utilisateur_login']= "valide";
 		
	         header('Location: compte.php');
		}
	}
  }
?>

	
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xml:lang="fr" xmlns="http://www.w3.org/1999/xhtml" lang="fr">

<head>
	
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Patrice Delpy </title>
<link href="../feuille.css" rel="stylesheet" type="text/css">


<script type="text/javascript" src="javascript.js"></script>


<script type="text/javascript">

function blabla(enregistrer)
{
	
	 if ( enregistrer.terms.checked == false )
        {
                alert ( "Vous devez accepter les conditions générales ci-dessous, merci." );
                valid = false;
        }
	/*var isCGVChecked = document.getElementById('publicite').checked;

	    if(!isCGVChecked)
		 {
			alert("Pour valider votre commande, merci de cocher la case concernant l'acception des conditions générales de vente")
			return false;
		 }*/
	
/*if (enregistrer.publicite.checked == false )
    {
    alert('Vous devez cocher la case avant de continuer.');
    return false;
    }
if (enregistrer.publicite.checked == true )
    {
    alert('Merci pour votre don');
    }
    return true;*/
	
  	
    
}

</script> 

</head>


<body class="gecko">
<div id="page">

<div id="header">
<h1><a name="top" href="/">Patrice Delpy</a></h1>
</div>
		
<?php		
	 include('../menu_site.php'); 

?>		

<div id="section">

<style type="text/css">
	.ElemNormal { margin-top:6px; }
	.ElemMandat { margin-top:6px; color:#0066FF; }
	.ValidatorError { color:#990000; }
	/* Exemple de newsletter */
	#news {padding: 0; text-align:center; margin-top:10px}
	#news li {display:inline; list-style-type:none; padding: 10px 20px 10px 20px}
	#news li img {border:0;}
</style>




<div id="client">
<div class="SideLeft">
<table class="CatTitle" border="0" cellpadding="0" cellspacing="0" width="100%">
<tbody>

<tr>
<th height="40" width="689"> Mon compte <img src="../images/PuceBleue.gif" alt="" height="11" width="8">
<hr>
</th>

<td rowspan="2" width="56"><img src="AccountHeaderIco.jpg" alt="" height="56" width="92">
</td>
</tr>

<tr>
<td style="vertical-align: top;" height="26"><a href="../acceuil.php">Accueil &gt;</a>
</td>
</tr>

</tbody>
</table>	
	
	
	
<br>
        
<form name="enregistrer" action="creation_compte.php"  method="post" onsubmit="return traitement(this);">

<table style="margin-left: 10px;" border="0" cellpadding="0" cellspacing="0" width="100%">
<tbody>
<tr>
<td style="vertical-align: top;" width="50%">
<table style="margin: 0pt;" class="ToolBox2" border="0" cellpadding="0" cellspacing="0" width="350px">
<tbody>
<tr>

<th width="5"><img src="../images/PromoBoxLeft.gif" height="22" width="5">
</th>

<th align="left" width="340">Mon identité  
<img src="../images/PromoBoxArrow.gif" style="display: inline;" height="11" width="8">
</th>

<th width="5">
<img src="../images/PromoBoxRight.gif" height="22" width="5">
</th>
</tr>

<tr style="background: url(&quot;/images/gui/main/CptidentIco.gif&quot;) no-repeat scroll right center transparent;">
<td class="Inner" colspan="3" style="padding: 5px 10px 10px;" align="left" height="100" valign="top" width="100%">

<div class="ElemMandat">Mon adresse e-mail </div>

<div>
<input name="email" id="email" style="height: 12px; font-size: 10px; width: 150px;"  type="text" onChange="verif_email(this.value)"> 								
</div>

<div id="email_box"><br></div>


<input type="hidden" name="valide" id="valide" value="">

<input type="hidden" name="valide_email" id="valide_email" value="">
<input type="hidden" name="valide_identifiant" id="valide_identifiant" value="">

<input type="hidden" name="pub" id="pub" value="">

<div class="ElemMandat">Mon nom d'utilisateur</div>

<div>
<input name="identifiant" id="identifiant" style="height: 12px; font-size: 10px; width: 150px;" maxlength="20" 
onChange="verif_identifiant(this.value)" type="text">
</div>
<div id="identifiant_box"><br></div>

<div class="ElemMandat">Mon mot de passe</div>

<div>
<input name="password1" id="password1" style="height: 12px; font-size: 10px; width: 150px;" value="" maxlength="10" type="password">
</div>

<div class="ElemMandat">Confirmation du mot de passe</div>

<div>
<input name="password2" id="password2" style="height: 12px; font-size: 10px; width: 150px;" value="" maxlength="10" type="password">
</div>

<br>

<div>
<input name="publicite" value="0" type="checkbox">
Oui, je souhaite m'inscrire à la newsletter</a> qui me permettra de recevoir par e-mail les promotions 
et les réductions exclusives proposées aux abonnés !.
</div>


									<div class="ElemNormal">Date de naissance</div>
									<select name="jour" id="jour">
									<option selected="selected"></option>
									<option value="1">1</option>
									<option value="2">2</option>
									<option value="3">3</option>
									<option value="4">4</option>
									<option value="5">5</option>
									<option value="6">6</option>
									<option value="7">7</option>
									<option value="8">8</option>
									<option value="9">9</option>
									<option value="10">10</option>
									<option value="11">11</option>
									<option value="12">12</option>
									<option value="13">13</option>
									<option value="14">14</option>
									<option value="15">15</option>
									<option value="16">16</option>
									<option value="17">17</option>
									<option value="18">18</option>
									<option value="19">19</option>
									<option value="20">20</option>
									<option value="21">21</option>
									<option value="22">22</option>
									<option value="23">23</option>
									<option value="24">24</option>
									<option value="25">25</option>
									<option value="26">26</option>
									<option value="27">27</option>
									<option value="28">28</option>
									<option value="29">29</option>
									<option value="30">30</option>
									<option value="31">31</option>
								        </select>

									<select name="mois" id="mois">
									<option selected="selected"></option>
									<option value="1">Janvier</option>
									<option value="2">Février</option>
									<option value="3">Mars</option>
									<option value="4">Avril</option>
									<option value="5">Mai</option>
									<option value="6">Juin</option>
									<option value="7">Juillet</option>
									<option value="8">Aout</option>
									<option value="9">Septembre</option>
									<option value="10">Octobre</option>
									<option value="11">Novembre</option>
									<option value="12">Décembre</option>
									</select>
																				
                                                                        <select name="annee" id="annee">
									<option selected="selected"></option>
									<option value="2010">2010</option>
									<option value="2009">2009</option>
									<option value="2008">2008</option>
									<option value="2007">2007</option>
									<option value="2006">2006</option>
									<option value="2005">2005</option>
									<option value="2004">2004</option>
									<option value="2003">2003</option>
									<option value="2002">2002</option>
									<option value="2001">2001</option>
									<option value="2000">2000</option>
									<option value="1999">1999</option>
									<option value="1998">1998</option>
									<option value="1997">1997</option>
									<option value="1996">1996</option>
									<option value="1995">1995</option>
									<option value="1994">1994</option>
									<option value="1993">1993</option>
									<option value="1992">1992</option>
									<option value="1991">1991</option>
									<option value="1990">1990</option>
									<option value="1989">1989</option>
									<option value="1988">1988</option>
									<option value="1987">1987</option>
									<option value="1986">1986</option>
									<option value="1985">1985</option>
									<option value="1984">1984</option>
									<option value="1983">1983</option>
									<option value="1982">1982</option>
									<option value="1981">1981</option>
									<option value="1980">1980</option>
									<option value="1979">1979</option>
									<option value="1978">1978</option>
									<option value="1977">1977</option>
									<option value="1976">1976</option>
									<option value="1975">1975</option>
									<option value="1974">1974</option>
									<option value="1973">1973</option>
									<option value="1972">1972</option>
									<option value="1971">1971</option>
									<option value="1970">1970</option>
									<option value="1969">1969</option>
									<option value="1968">1968</option>
									<option value="1967">1967</option>
									<option value="1966">1966</option>
									<option value="1965">1965</option>
									<option value="1964">1964</option>
									<option value="1963">1963</option>
									<option value="1962">1962</option>
									<option value="1961">1961</option>
									<option value="1960">1960</option>
									<option value="1959">1959</option>
									<option value="1958">1958</option>
									<option value="1957">1957</option>
									<option value="1956">1956</option>
									<option value="1955">1955</option>
									<option value="1954">1954</option>
									<option value="1953">1953</option>
									<option value="1952">1952</option>
									<option value="1951">1951</option>
									<option value="1950">1950</option>
									<option value="1949">1949</option>
									<option value="1948">1948</option>
									<option value="1947">1947</option>
									<option value="1946">1946</option>
									<option value="1945">1945</option>
									<option value="1944">1944</option>
									<option value="1943">1943</option>
									<option value="1942">1942</option>
									<option value="1941">1941</option>
									<option value="1940">1940</option>
									<option value="1939">1939</option>
									<option value="1938">1938</option>
									<option value="1937">1937</option>
									<option value="1936">1936</option>
									<option value="1935">1935</option>
									<option value="1934">1934</option>
									<option value="1933">1933</option>
									<option value="1932">1932</option>
									<option value="1931">1931</option>
									<option value="1930">1930</option>
									<option value="1929">1929</option>
									<option value="1928">1928</option>
									<option value="1927">1927</option>
									<option value="1926">1926</option>
									<option value="1925">1925</option>
									<option value="1924">1924</option>
									<option value="1923">1923</option>
									<option value="1922">1922</option>
									<option value="1921">1921</option>
									<option value="1920">1920</option>
									</select>
									<div>

<!--

<table style="margin-top: 6px;" border="0" cellpadding="0" cellspacing="0" width="100%">
<tbody>
<tr>
<td class="ElemMandat" valign="top" width="57">Je suis </td>

<td valign="top" width="157">
<input name="type" value="0" id="type0" checked="checked" onclick="TvaBox(false); SocieteBox(false,'');" type="radio">
<label for="type0">un particulier</label>
<br>

<input name="type" value="1" id="type1" onclick="TvaBox(true); SocieteBox(true,'Société : ');" type="radio">
<label for="type1">une entreprise</label>
<br>

<input name="type" value="2" id="type2" onclick="TvaBox(true); SocieteBox(true,'Administration : ');" type="radio">
<label for="type2">une administration</label>
<br>

<input name="type" value="3" id="type3" onclick="TvaBox(true); SocieteBox(true,'Association : ');" type="radio">
<label for="type3">une association</label>
</td>

<td valign="top" width="130"></td>
</tr>
</tbody>
</table>

-->
									
<div class="ElemMandat">Téléphone : 
</div>
										
<div>
<input name="telephone" id="telephone" maxlength="10" style="height: 12px; font-size: 10px; width: 150px;" type="text"> 										</div>

<div class="ElemNormal">Autre numéro de téléphone : 
</div>

<div>
<input name="autre_telephone" id="autre_telephone" maxlength="10" style="height: 12px; font-size: 10px; width: 150px;" type="text"> 										</div>

<div class="ElemNormal">fax : 
</div>

<div>
<input name="fax" id="fax" maxlength="10" style="height: 12px; font-size: 10px; width: 150px;" type="text"> 	
</div>

</div>

<div style="color: rgb(144, 144, 144); margin-top: 10px;">
Vous devez impérativement indiquer un numéro de téléphone fixe ou portable et
une adresse e-mail. Ces informations sont indispensables pour que votre
commande soit enregistrée et traitée.</div>

				</td>
				</tr>
				</tbody>
				</table>
				</td>
                    
                    
<td style="vertical-align: top; padding-left: 2px;" width="50%">
<table class="ToolBox2" style="margin: 0pt;" border="0" cellpadding="0" cellspacing="0" width="350px">
<tbody>
<tr>
<th width="5"><img src="../images/PromoBoxLeft.gif" height="22" width="5">
</th>

<th align="left" width="340">Mon adresse de facturation  
<img src="../images/PromoBoxArrow.gif" style="display: inline;" height="11" width="8">

</th>
<th width="5">
<img src="../images/PromoBoxRight.gif" height="22" width="5"></th>
</tr>
<tr>

<td class="Inner" colspan="3" style="padding: 5px 10px 10px; background: url(../images/CptAddrIco.jpg;) no-repeat 
scroll right center transparent;" align="left" height="100" valign="top" width="100%">

<div class="AccSmall">
<input name="civ" value="1" id="civ1" type="radio">
<label for="civ1">M.</label>
<input name="civ" value="2" id="civ2" type="radio">
<label for="civ2">Mme</label>
<input name="civ" value="3" id="civ3" type="radio">
<label for="civ3">Mlle</label>
</div>

<div class="ElemMandat">Nom : </div>

<div>
<input name="nom" id="nom" style="height: 12px; font-size: 10px; width: 150px;" type="text">
</div>

<div class="ElemMandat">Prénom : </div>

<div>
<input name="prenom" id="prenom" style="height: 12px; font-size: 10px; width: 150px;" type="text">
</div>

<div class="ElemMandat" id="SocieteBlock" style="display: none;">

<div class="ElemNormal" id="labelsociete"></div>

<div>
<input name="societe" id="societe" style="height: 12px; font-size: 10px; width: 150px;" type="text">
</div>

</div>

<div class="ElemMandat">Adresse : </div>


<div>
<input name="adr1" id="adr1" style="height: 12px; font-size: 10px; width: 150px;" maxlength="60" type="text">
</div>

<div class="ElemNormal">Complément d'adresse : 
</div>

<div>
<input name="adr2" id="adr2" style="height: 12px; font-size: 10px; width: 150px;" maxlength="60" type="text">
</div>

<div class="ElemMandat">Code postal : 
</div>

<div>
<input name="cp" id="cp" style="height: 12px; font-size: 10px; width: 150px;" maxlength="5" type="text">
</div>

<div class="ElemMandat">Ville : </div>

<div>
<input name="ville" id="ville" style="height: 12px; font-size: 10px; width: 150px;" type="text"> 								
</div>

<div id="TvaBlock" style="display: none;">

<div class="ElemNormal">Numéro de TVA : </div>

<div>
<input name="tva" id="tva" style="height: 12px; font-size: 10px; width: 150px;" type="text">
</div>

</div>
				
				</td>
				</tr>
				</tbody>
				</table>
				</td>
				</tr>
				<tr>

<td colspan="2">
<table class="ToolBox2" style="margin-top: 10px;" border="0" cellpadding="0" cellspacing="0" width="725px">
<tbody><tr>
<th width="5">
<img alt="" src="register_fichiers/PromoBoxLeft.gif" height="22" width="5"></th>

<th align="left" width="715">Validation <img alt="" style="display: inline;" src="../images/PromoBoxArrow.gif" height="11" width="8"></th>
<th width="5"><img alt="" src="PromoBoxRight.gif" height="22" width="5"></th>
</tr><tr>
<td class="Inner" style="padding: 10px;" colspan="3" 
align="left" height="100" valign="top" width="625">
<!--
<input name="verif" id="verif" type="checkbox">
<label 
for="verif"> Je certifie exactes les informations renseignées dans les 
champs ci-dessus et conforme à chaque libellé et accepte que celles-ci 
servent de base à la facturation de mes prochaines commandes.</label>
<br>
-->

<input type="checkbox" name="termes" value="oui"> Je certifie exactes les informations renseignées dans les 
champs ci-dessus et conforme à chaque libellé et accepte que celles-ci 
servent de base à la facturation de mes prochaines commandes.

<input name="imageField" src="../images/btn_nextstep.gif" style="margin-top: 10px; float: right;" type="image">

				</td>
				</tr>
				</tbody>
				</table>
				</td>
				</tr>
				</tbody>
				</table>
				</form>
  
  			<div id="aside">
			<div id="search-bar">

			<form method="get" action="recherche.html">
			<input type="text" name="search" title="Recherche"/>
			<input type="submit" value="Rechercher" />
			</form>
			</div>

<?php
            
            //if(isset($_SESSION['connexion']))
			 
			    if($_SESSION['utilisateur_login']== "valide")
			      {         
				            //echo '<body onLoad="alert(\'Identification par le panel.\')">'; 
							echo "
								<div id=\"account\" class=\"on\">
								<ul>
								<li class=\"icon\"><a href=\"compte.php\">Mon espace perso</a></li>
								<li class=\"logout\"><a href=\"logout.php\" title=\"Me d&eacute;connecter\">Me d&eacute;connecter</a></li>
								</ul>
								<div class=\"panel\">
								<ul class=\"buttons\">
								<li class=\"account\"><a href=\"compte.php\">Mon compte client</a></li>
								<li class=\"orders\"><a href=\"../commande/suivi_commande.php\">Mes commandes</a></li>
								<li class=\"addresses\"><a href=\"adresse_livraison.php\">Mon carnet d'adresse</a></li>
								<li class=\"repairs\"><a href=\"sav.html\">Mes retours S.A.V</a></li>
								<li class=\"parrainages\"><a href=\"parrainage.html\">Mes parrainages</a></li>
								<li class=\"refunds\"><a href=\"avoir.html\">Mes avoirs</a></li>
								<li class=\"carts\"><a href=\"../panier/shopping_liste.php\">Mes paniers</a></li>
								<li class=\"alertes\"><a href=\"alerte.html\">Mes alertes</a></li>
								</ul>
								</div>
								</div> ";
				}
					 
			   else {
						 		echo "
						 		<div id=\"account\">
								<ul>
								<li class=\"icon\"><a href=\"login.php\">Mon espace perso</a></li>
								</ul>

								<div class=\"panel\">
								<form action=\"check.php\" method=\"post\">
								<dl>
								<dt><label for=\"login\">Votre nom utilisateur</label></dt>
								<dd><input name=\"login\" id=\"login\" maxlength=\"20\" type=\"text\"></dd>
								<dt><label for=\"pass\">Votre mot de passe</label></dt>
								<dd><input name=\"pass\" id=\"pass\" maxlength=\"10\" type=\"password\"></dd>
								</dl>
								<input value=\"Connexion\" type=\"submit\">
								<hr>
								<ul class=\"buttons\">
								<li class=\"register\"><a href=\"creation_compte.php\">Créer mon compte</a></li>
								<li class=\"password\"><a href=\"sendpass.html\">Mot de passe oublié ?</a></li>
								</ul>
								</form>
								</div>
								</div> ";
						 
				}

?>

<div id="basket" >
	<ul>
		<li id="BasketProdCount"><a href="../panier/panier.php">Votre panier est vide</a></li>
		<li id="BasketAmount"></li>
	</ul>
</div>
	</div>
	
	</div>			
	</div>


	</div>
        
	</body>
    	</html>