Location: PHPKode > projects > Pnyx : des lections virtuelles! > pnyx1.0.1/ele_vote2.php
<?php

	#########################################################################################
	# Gestion du vote des élèves de Pnyx - scripts bdd										#
	# Auteur : V. Blais																		#
	# Création : 2006-04-05																	#
	# Modification : 2008-09-03																#
	# 																						#
	# Pnyx - une application Web (PHP/MySQL) d'élections virtuelles conçue pour	des	élèves	#
	# du primaire et du secondaire, dans lequel ils sont amenés à faire des	propositions	#
	# en ligne et voter pour leur favorite, sous la supervision d'un enseignant.			#
	#																						#
    # Copyright (C) <2008 - 2009>															#
	# <Service national du RÉCIT de l'univers social de la Commission scolaire de la		#
	# Pointe-de-l'Île>																		#
	#																						#
	# This program is free software; you can redistribute it and/or modify it under the 	#
	# terms of the GNU General Public License as published by the Free Software Foundation.	#
	# This program is distributed in the hope that it will be useful, but WITHOUT ANY 		#
	# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 		#
	# PARTICULAR PURPOSE.  See the GNU General Public License for more details.				#
	# You should have received a copy of the GNU General Public License along with this 	#
	# program as the file LICENSE.txt; if not, please see 									#
	# http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.									#
	# 																						#
	# Service national du RÉCIT de l'univers social											#
	# http://www.recitus.qc.ca																#
	# Contact e-mail : steve-hide@address.com												#
	#########################################################################################

	require "entete_php.php";
	
	if ($HTTP_POST_VARS['type_action'] == "vote"){
		
		$requete_sql = "SELECT * FROM election
    					WHERE finaliste_id = \"$HTTP_POST_VARS[id_final]\"
						";
		$reponse_app = bd_executer_sql($requete_sql);
		$ligne = mysql_fetch_array($reponse_app);
		
		$requete_sql = "UPDATE eleve 
						SET fiche_vote = \"$ligne[fiche_id]\", 
						justification = \"".addslashes($HTTP_POST_VARS["texte"])."\",
						vote = '1'
						WHERE projet_id = $projet
						AND eleve_id = $usager
    					";
		$reponse_msg = bd_executer_sql($requete_sql);
		
		$vote = $ligne['nb_votes'] +1;
		
		$requete_sql = "UPDATE election
						SET nb_votes = $vote
    					WHERE finaliste_id = \"$HTTP_POST_VARS[id_final]\"
						";
		$reponse_app = bd_executer_sql($requete_sql);
		
		$HTTP_SESSION_VARS['SESSION']['message'] = "Ton vote est enregistré!";
		
		$page = "ele_vote.php";
		header("Location: $page");
	}
	
	if ($HTTP_GET_VARS['type_action'] == "aff_fiche"){
		
		if (!session_is_registered("RETOUR")){
			session_register("RETOUR");
		}
	
		$HTTP_SESSION_VARS["RETOUR"] = "<a href='".$HTTP_GET_VARS['page']."'>Retour à la page de vote</a>";
		
		$page = "gen_fiche.php?id_prop=".$HTTP_GET_VARS['id_prop']."&pos=".$HTTP_GET_VARS['pos']."&autre=n";
		header("Location: $page");
	}
	
	
	
	
	

?>
Return current item: Pnyx : des lections virtuelles!