MOD déplacement des fichiers php dans le dossier PHP (sauf index.php)
[cl7.git] / php / connexion.php
diff --git a/php/connexion.php b/php/connexion.php
new file mode 100644 (file)
index 0000000..6b5e26c
--- /dev/null
@@ -0,0 +1,39 @@
+<?php\r
+/*\r
+ * Connexion à la base de donnée + résolutiondu participant.\r
+ * Produit une variable globale nommée '$le_participant'.\r
+ */
+\r
+include_once("config.php");
+include_once("class_participant.php");\r
+
+$lien_mysql = mysql_connect($SQL_HOTE, $SQL_LOGIN, $SQL_PASS);
+mysql_select_db($NOM_BASE);\r
+mysql_set_charset("UTF8");\r
+mysql_query('SET AUTOCOMMIT=0');
+
+if (isset($_POST['effacer_cookie'])) # le membre se délogue
+{
+   setcookie("COOKIE_INFO_PATICIPANT", "", time() - 100); #'efface' le cookie membre
+   unset($HTTP_COOKIE_VARS["COOKIE_INFO_PATICIPANT"]);
+       unset($log);
+}
+
+if (isset($_POST['log'])) # le membre se logue
+{              
+   $le_participant = new Participant($pseudo, $password);
+   if ($le_participant->valide)
+   {
+      setcookie ("COOKIE_INFO_PATICIPANT", $le_participant->info->id, time() + 31104000);              
+   }
+}
+else if (isset($HTTP_COOKIE_VARS["COOKIE_INFO_PATICIPANT"])) # le cookie existe deja chez le participant\r
+{
+   $le_participant = new Participant($HTTP_COOKIE_VARS["COOKIE_INFO_PATICIPANT"]);\r
+}
+else\r
+{
+       $le_participant = new Participant();\r
+}
+
+?>
\ No newline at end of file