function poll_vote in Drupal 6
Same name and namespace in other branches
- 4 modules/poll.module \poll_vote()
- 5 modules/poll/poll.module \poll_vote()
- 7 modules/poll/poll.module \poll_vote()
Submit handler for processing a vote
1 string reference to 'poll_vote'
- poll_view_voting in modules/
poll/ poll.module - Generates the voting form for a poll.
File
- modules/
poll/ poll.module, line 588 - Enables your site to capture votes on different topics in the form of multiple choice questions.
Code
function poll_vote($form, &$form_state) {
$node = $form['#node'];
$choice = $form_state['values']['choice'];
global $user;
if ($user->uid) {
db_query('INSERT INTO {poll_votes} (nid, chorder, uid) VALUES (%d, %d, %d)', $node->nid, $choice, $user->uid);
}
else {
db_query("INSERT INTO {poll_votes} (nid, chorder, hostname) VALUES (%d, %d, '%s')", $node->nid, $choice, ip_address());
}
// Add one to the votes.
db_query("UPDATE {poll_choices} SET chvotes = chvotes + 1 WHERE nid = %d AND chorder = %d", $node->nid, $choice);
cache_clear_all();
drupal_set_message(t('Your vote was recorded.'));
// Return the user to whatever page they voted from.
}