Avoid multiple insertion
Avoid multiple insertion of the same word on the same vote
This commit is contained in:
parent
844ca51a49
commit
ce1f76a96c
1 changed files with 3 additions and 1 deletions
4
save.php
4
save.php
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue