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

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

if( strlen($_POST['description']) < 3 || strlen($_POST['intitule']) < 3){
	Header("Location: ".$_SERVER['HTTP_REFERER']."?alert=".urlencode('Il y a une erreur. Veuillez réessayer.')."#".$_GET['tab']);
	exit();
}
else{
	if($_POST['id_competence'] == "new"){
		dbquery("INSERT INTO cv_competences(id_cv,intitule,description) VALUES('".$_SESSION['user']['id_cv']."','".addslashes($_POST['intitule'])."','".addslashes($_POST['description'])."') ");
	}
	else{
		dbquery("UPDATE cv_competences 
					SET id_cv = '".$_SESSION['user']['id_cv']."', 
						intitule = '".addslashes($_POST['intitule'])."', 
						description = '".addslashes($_POST['description'])."' 
					WHERE id_competence_cv = ".$_POST['id_competence']." ");
	}

	Header("Location: ".$_SERVER['HTTP_REFERER']."#".$_GET['tab']);
	exit();
}

?>