Avoid multiple insertion

Avoid multiple insertion of the same word on the same vote
This commit is contained in:
Gregory Trolliet 2020-11-23 21:59:39 +01:00
parent 844ca51a49
commit ce1f76a96c

View file

@ -9,13 +9,15 @@ include 'templates/header.php';
$id = null; $id = null;
$cpt = 0; $cpt = 0;
$already_used = array();
foreach ($_POST as $name => $value) { foreach ($_POST as $name => $value) {
$cpt; $cpt;
if ($name == 'fid') { if ($name == 'fid') {
$id = $value; $id = $value;
continue; continue;
} }
if (isset($id)) { if (isset($id) && !in_array($value, $already_used)) {
$already_used[] = $value;
$value = trim(strtolower($value)); $value = trim(strtolower($value));
$db->addWord($id, $value); $db->addWord($id, $value);
} }