<?php
require($_SERVER['DOCUMENT_ROOT'].'/espace_personnel/inc/head-lib.php');

if(!isset($_GET['id_cv'])){
	$q = "INSERT INTO cv_auditeurs(id_auditeur,nom_cv) VALUES ( '".$_SESSION['user']['id']."' , '".$_POST['nom_cv']."' ) " ;

	dbquery($q);

	$sql = dbquery("SELECT * FROM cv_auditeurs WHERE id_auditeur='".$_SESSION['user']['id']."' ORDER BY id_cv DESC LIMIT 1 ");

	$_SESSION['user']['id_cv'] = dbresult_utf8($sql,0,"id_cv");
}
else{
	$sql = dbquery("SELECT * FROM cv_auditeurs WHERE id_auditeur = '".$_SESSION['user']['id']."' AND id_cv = '".$_GET['id_cv']."'  ");

	if(dbnumrows($sql) == 0){
		Header("Location: /espace_personnel/eleve/cv/index.php?alert=".urlencode('L\'opération a échoué.')." ");
	}
	else{
		$_SESSION['user']['id_cv'] = $_GET['id_cv'];
	}
}

//echo "<pre>";print_r($_SESSION);echo "</pre>";

Header("Location: /espace_personnel/eleve/cv/form.php");
?>