119 lines
3.6 KiB
PHP
119 lines
3.6 KiB
PHP
<?php
|
|
ini_set('display_errors', 1);
|
|
ini_set('display_startup_errors', 1);
|
|
error_reporting(E_ALL);
|
|
session_start();
|
|
$_SESSION['error_msg'] = "";
|
|
$root = realpath($_SERVER["DOCUMENT_ROOT"]);
|
|
|
|
require "$root/lang/gettext.php";
|
|
require "$root/database/credentials.php";
|
|
// Connect the database
|
|
try {
|
|
$db = new PDO("mysql:host=$host;dbname=$database;charset=utf8",
|
|
$user,
|
|
$password,
|
|
array(PDO::ATTR_ERRMODE => 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');
|
|
?>
|