Supply filetype when adding new file.
[mediadatabase.git] / php / categories.php
blob9479e07ca1bdc9aeacd855147f265563be0ed31c
1 <?php
3 require('inc.header.php');
5 if (isset($_POST['cat_add']) && strlen($_POST['cat_add']) > 0) {
6 if (!$res = mysql_query("INSERT INTO ".$config['tbl_categories']." VALUES (NULL,'".addslashes($_POST['cat_add'])."')")) {
7 echo "<b>Error:</b> ".mysql_error()." <i>(".basename(__FILE__).", line ".__LINE__.")</i>\n<p>\n";
8 } else {
9 if (!mysql_affected_rows()) {
10 echo "Could not add category.\n<p>\n";
11 } else {
12 echo "Category added.\n<p>\n";
18 if (!$res = mysql_query("SELECT * FROM ".$config['tbl_categories']." ORDER BY name")) {
19 echo "<b>Error:</b> ".mysql_error()." <i>(".basename(__FILE__).", line ".__LINE__.")</i>\n\n";
20 } else {
21 if (!mysql_num_rows($res)) {
22 echo "No categories!\n";
23 } else {
24 echo "<b>Categories</b>\n";
25 echo "<ul>\n";
26 while (list($id,$name) = mysql_fetch_row($res)) {
27 echo " <li>$name\n";
29 echo "</ul>\n";
33 echo "<form action=\"$self\" method=\"post\">\n";
34 echo " Add category <input type=\"text\" name=\"cat_add\">\n";
35 echo " <input type=\"submit\" value=\"Add\">\n";
36 echo "</form>\n";
38 require('inc.footer.php');