Generalization of the dbname
diff --git a/admin/createtable.php b/admin/createtable.php
index 375225b..57e1802 100644
--- a/admin/createtable.php
+++ b/admin/createtable.php
@@ -22,9 +22,9 @@
`assassi` int(11) NOT NULL,
`curs` tinyint(1) NOT NULL,
`grau` tinyint(1) NOT NULL,
- `data` date NOT NULL DEFAULT current_timestamp()
+ `data` timestamp NOT NULL DEFAULT current_timestamp()
)"];
- foreach ($queries as $query) if (!query($query)) die('An error ocurred.');
+ foreach ($queries as $query) if (!query($query)) die('An error ocurred. ' . $query);
die("<script>window.location.href = './index.php?dbname=$dbname'</script>");
?>
diff --git a/admin/insert.php b/admin/insert.php
index 6f793a1..5099bc7 100644
--- a/admin/insert.php
+++ b/admin/insert.php
@@ -8,17 +8,19 @@
// Read from CSV
$inscrits = array_map('str_getcsv', file($csvname));
array_shift($inscrits); // remove header
+ shuffle($inscrits); // shuffle randomly
$start = 1;
$i = $start;
foreach ($inscrits as $user) {
$i = ($i + 1) % ($start + count($inscrits));
if ($i == 0) $i = $i + 1;
- $template = "INSERT INTO `".$dbname."` (`id`, `nom`, `curs`, `grau`, `quimata`, `requested`, `mort`, `password`, `bits`)" .
- " VALUES (NULL, '".$user[0]."', '".$user[1]."', '".$user[2]."', ".$i.", 0, 0, '', ".(int)rand(1,512).")";
+ // Input values into SQL values
+ $template = "INSERT INTO `$dbname` (`id`, `nom`, `curs`, `grau`, `quimata`, `requested`, `mort`, `password`, `bits`)" .
+ " VALUES (NULL, '$user[0]', '$user[1]', '$user[2]', $i, 0, 0, '', ".(int)rand(1,512).")";
- if (!query($template)) die("An error ocurred.");
+ if (!query($template)) die("An error ocurred." . $template);
}
- die("<script>window.location.href = './index.php'</script>");
+ die("<script>window.location.href = './index.php?successinserting'</script>");
?>