diff --git a/public/explore/list/index.php b/public/explore/list/index.php index edccc66..f86e9a9 100755 --- a/public/explore/list/index.php +++ b/public/explore/list/index.php @@ -26,7 +26,7 @@ $result = $req->fetchAll(); - <?_('Explore')?> | Chiro - Canto + <?=_('Explore')?> | Chiro - Canto diff --git a/public/explore/record/edit/index.php b/public/explore/record/edit/index.php index 804fd64..e38659d 100644 --- a/public/explore/record/edit/index.php +++ b/public/explore/record/edit/index.php @@ -3,10 +3,9 @@ ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL); session_start(); -session_reset(); +$_SESSION['error_msg'] = ""; $root = realpath($_SERVER["DOCUMENT_ROOT"]); -$lang = isset($_COOKIE['lang']) ? $_COOKIE['lang'] : 'en'; -require("$root/lang/$lang/lang.php"); +require("$root/lang/gettext.php"); require "$root/database/credentials.php"; // Connect the database try { @@ -47,7 +46,7 @@ if (isset($_GET['id'])){ if ($data = $req->fetch()){ ?>
- + @@ -60,7 +59,7 @@ if (isset($_GET['id'])){ - + @@ -70,6 +69,7 @@ if (isset($_GET['id'])){ +
PDO::ERRMODE_EXCEPTION + )); +} catch (Exception $e) { + die("Error : ".$e->getMessage()); +} + +if (isset($_POST['submit'])) { + if (isset($_POST['id'])) { + $id = $_POST['id']; + $req = $db->prepare('SELECT * FROM `records` WHERE id=:id'); + $req->execute(array( + "id"=>$id + )); + $data = $req->fetch(); + } else { + $_SESSION['error_msg'] .= _('You did not specify any record id.'); + header('Location: /explore/list'); + } + if (isset($_POST['date'])) { + $date = $_POST['date']; + if ($date != $data['date']) { + $req = $db->prepare('UPDATE `records` SET date=:date WHERE id=:id'); + $req->execute(array( + "id"=>$id, + "date"=>$date + )); + } + } + if (isset($_POST['time'])) { + $time = $_POST['time']; + if ($time != $data['time']) { + $req = $db->prepare('UPDATE `records` SET time=:time WHERE id=:id'); + $req->execute(array( + "id"=>$id, + "time"=>$time + )); + } + } + if (isset($_POST['recordist-name'])) { + $recordist = $_POST['recordist-name']; + if ($recordist != $data['recordist_name']) { + $req = $db->prepare('UPDATE `records` SET recordist_name=:recordist_name WHERE id=:id'); + $req->execute(array( + "id"=>$id, + "recordist_name"=>$recordist + )); + } + } + if (isset($_POST['species'])) { + $species = $_POST['species']; + if ($species != $data['species']) { + $req = $db->prepare('UPDATE `records` SET species=:species WHERE id=:id'); + $req->execute(array( + "id"=>$id, + "species"=>$species + )); + } + } + if (isset($_POST['subspecies'])) { + $subspecies= $_POST['subspecies']; + if ($subspecies != $data['subspecies']) { + $req = $db->prepare('UPDATE `records` SET subspecies=:subspecies WHERE id=:id'); + $req->execute(array( + "id"=>$id, + "subspecies"=>$subspecies + )); + } + } + if (isset($_POST['make'])) { + $make = $_POST['make']; + if ($make != $data['make']) { + $req = $db->prepare('UPDATE `records` SET make=:make WHERE id=:id'); + $req->execute(array( + "id"=>$id, + "make"=>$make + )); + } + } + if (isset($_POST['model'])) { + $recordist = $_POST['model']; + if ($model != $data['model']) { + $req = $db->prepare('UPDATE `records` SET model=:model WHERE id=:id'); + $req->execute(array( + "id"=>$id, + "model"=>$model + )); + } + } + if (isset($_POST['serial'])) { + $serial = $_POST['serial']; + if ($serial != $data['serial']) { + $req = $db->prepare('UPDATE `records` SET serial=:serial WHERE id=:id'); + $req->execute(array( + "id"=>$id, + "serial"=>$serial + )); + } + } + header('Location: /explore/list'); +} else { + $_SESSION['error_msg'] .= _('You did not submit the form.'); +} +header('Location: /explore/list'); +?> \ No newline at end of file