chiro-canto/public/explore/record/edit/index.php

86 lines
3.9 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($_GET['id'])){
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title><?=_('Edit')?> | Chiro - Canto</title>
<link rel="stylesheet" type="text/css" href="/styles/style.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
</head>
<?php
include("$root/analytics/matomo.php");
include("$root/analytics/owa.php");
?>
<body>
<?php include("$root/menu.php");?>
<?php include("$root/header.php");?>
<section>
<h2><?=_('Edit')?></h2>
<?php
$req = $db->prepare('SELECT * FROM records WHERE id=:id');
$req->execute(array(
"id"=>$_GET['id']
));
if ($data = $req->fetch()){
?>
<form action="update.php" method="post">
<input type="hidden" name="id" value="<?=$_GET['id']?>" readonly>
<label for="file_name"><?=_('File Name')?>*</label>
<input type="text" id="file_name"value="<?=$data['file_name']?>" readonly>
<label for="coordinates"><?=_('Coordinates')?>*</label>
<input type="text" id="coordinates" value="<?=$data['lat']?>, <?=$data['lng']?>" readonly>
<label for="date"><?=_('Date')?>*</label>
<input type="date" name="date" id="date" value="<?=$data['date']?>">
<label for="time"><?=_('Time')?>*</label>
<input type="time" name="time" id="time" value="<?=$data['time']?>">
<label for="recordist-name"><?=_('Recordist Name')?>*</label>
<input type="text" name="recordist-name" id="recordist-name" value="<?=$data['recordist_name']?>" required>
<label for="species"><?=_('Species')?>*</label>
<input type="text" name="species" id="species" value="<?=$data['species']?>">
<label for="subspecies"><?=_('Subspecies')?></label>
<input type="text" name="subspecies" id="subspecies" value="<?=$data['subspecies']?>">
<label for="make"><?=_('Recorder Manufacturer')?></label>
<input type="text" name="make" id="make" value="<?=$data['make']?>">
<label for="model"><?=_('Recorder Model')?></label>
<input type="text" name="model" id="model" value="<?=$data['model']?>">
<label for="serial"><?=_('Recorder Serial Number')?></label>
<input type="text" name="serial" id="serial" value="<?=$data['serial']?>">
<input type="submit" value="<?=_('submit')?>">
</form>
<?php
} else {
$_SESSION['error_msg'] = _("Can't fetch information on record with id") . "'".$_GET['id']."'";
}
echo $_SESSION['error_msg'];
?>
</section>
<?php include("$root/footer.php");?>
</body>
<script src="/scripts/script.js"></script>
</html>
<?php
}