vote.php

 1: <?php
 2: /****************************************************************************
 3:  * DRBPoll
 4:  * http://www.dbscripts.net/poll/
 5:  *
 6:  * Copyright � 2007-2009 Don B
 7:  ****************************************************************************/
 8: 
 9: require_once(dirname(__FILE__) . '/poll.php');
10: 
11: function show_error() {
12: 	global $vote_error_message;
13: 	echo(htmlspecialchars($vote_error_message));
14: }
15: 
16: // Handle action
17: if(isset( $_POST[$POLL_ID_PARAM_NAME] ) ) {
18: 
19: 	// Reset error message
20: 	global $vote_error_message;
21: 	$vote_error_message = NULL;
22: 
23: 	// Get parameter values from post
24: 	$poll_id = trim($_POST[$POLL_ID_PARAM_NAME]);
25: 	if(isset( $_POST[$VOTE_PARAM_NAME] )) {
26: 		$vote = trim($_POST[$VOTE_PARAM_NAME]);
27: 	} else {
28: 		$vote = NULL;
29: 	}
30: 
31: 	// For use in template functions
32: 	global $requested_poll_id;
33: 	$requested_poll_id = $poll_id;
34: 
35: 	// Attempt to add a new rating
36: 	if(add_new_vote($poll_id, $vote) === TRUE) {
37: 
38: 		// Display success page
39: 		include_once(dirname(__FILE__) . '/template/success.php');
40: 
41: 	} else {
42: 
43: 		// Display error page
44: 		include_once(dirname(__FILE__) . '/template/failure.php');
45: 
46: 	}
47: 
48: } else {
49: 
50: 	die("Invalid request.");
51: 
52: }
53: 
54: ?>