<?php
	require_once ('../common/scripts/templatize.inc.php');
	require_once ('../common/scripts/emblemize.inc.php');
	require_once ('../common/scripts/bdd.inc.php');
	require_once ('../common/scripts/persoGD.inc.php');
	
/***********************/
/*traitement           */
/***********************/
	if (strlen($_POST['mimichant_name'])>=24) die('Taille du nom du mimichant trop grande !');
	if (strlen($_POST['mimichant_description'])>=128) die('Infos sur les mimichants trop longues !');
	
	//cree l'image du mimichant
	creeMimichant($_POST['hidden_queue']+1,$_POST['hidden_corps']+1,$_POST['hidden_tete']+1,$_POST['hidden_oreille']+1,$_POST['hidden_color']);
	
	//on recupere la session
	session_start();
	
	//si on vient pas de la page de debut d'inscription, on evite le risque de bugs en revenant au debut
	if ($_SESSION['checkRegisterValue'] != -1 || $_POST['formLogin'] == '') header("Location: ./inscription.php");
	
	//on choisit un nombre aleatoire anti-spam
	$_SESSION['checkRegisterValue'] = rand(1000,9999);
	
	//on met les infos sous forme de variables de session, 
	//pour pouvoir continuer a les balader dans la page suivante
	
	$_SESSION['register_login'] = $_POST['formLogin'];
	$_SESSION['register_password'] = $_POST['formpassword'];
	
	$_SESSION['register_mimichant_ears'] = $_POST['hidden_oreille']+1;
	$_SESSION['register_mimichant_head'] = $_POST['hidden_tete']+1;
	$_SESSION['register_mimichant_corps'] = $_POST['hidden_corps']+1;
	$_SESSION['register_mimichant_tail'] = $_POST['hidden_queue']+1;
	$_SESSION['register_mimichant_color'] = $_POST['hidden_color'];
	
	$_SESSION['register_mimichant_name'] = $_POST['mimichant_name'];
	$_SESSION['register_mimichant_sex'] = $_POST['mimichant_sex'];
	$_SESSION['register_mimichant_description'] = $_POST['mimichant_description'];

/**************/
/*affichage   */
/**************/
	
	$arrayVars = array(
		'ADDITIONNAL_HEADERS' =>'<script type="text/javascript" src="ajax_inscription/verifierGuilde.js"></script>',
		'EMBLEMES_PREEXISTANTS' => emblemize('../emblemes_preexistants')
		);
	
	templatizeWithVars('../common/header.tpl','../common/menu.tpl', 'suiteInscription.tpl','../common/footer.tpl', $arrayVars);
?>
