simpleWordsCloud/save.php
Gregory Trolliet ce1f76a96c Avoid multiple insertion
Avoid multiple insertion of the same word on the same vote
2020-11-23 22:00:02 +01:00

30 lines
532 B
PHP

<?php
include('init.php');
if (empty($_POST)) {
header('Location: index.php');
die();
}
include 'templates/header.php';
$id = null;
$cpt = 0;
$already_used = array();
foreach ($_POST as $name => $value) {
$cpt;
if ($name == 'fid') {
$id = $value;
continue;
}
if (isset($id) && !in_array($value, $already_used)) {
$already_used[] = $value;
$value = trim(strtolower($value));
$db->addWord($id, $value);
}
if ($cpt > 9) {
break;
}
}
echo sprintf('<h3>%s</h3>', L::save_success);
include 'templates/footer.php';