Inital Commit

This commit is contained in:
2022-01-21 16:01:56 +01:00
commit ab40ebe2ce
15 changed files with 351 additions and 0 deletions

44
Editor-Save.php Normal file
View File

@@ -0,0 +1,44 @@
<style>
a.button {
background-color: Gainsboro;
border: none;
color: black;
padding: 10px 10px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
}
</style>
<?php
include 'db.php';
//Debug
echo "<br>";echo "ID:"; echo $_POST["TheID"];echo "<br>";
//EndDebugs
//Check if data was send
if (empty($_POST["TheNewData"])) {
echo 'No data has been submitted <br><button onclick="history.back()">Go Back</button>';
}
else {
$stmt = $mysqli->prepare("SELECT TRUE FROM ImgAnnotations WHERE id = ? LIMIT 1");
$stmt->bind_param("i", $_POST["TheID"]);
$stmt->execute();
$result = $stmt->get_result(); // get the mysqli result
if( mysqli_num_rows($result) > 0) {
//ID does exits, updating";
$stmt = $mysqli->prepare("UPDATE ImgAnnotations SET data = ? WHERE id = ?");
$stmt->bind_param("si", $_POST["TheNewData"], $_POST["TheID"]);
}else {
//ID doesn't exits, creating";
$stmt = $mysqli->prepare("INSERT INTO ImgAnnotations (id, data) VALUES (?, ?)");
$stmt->bind_param("is", $_POST["TheID"], $_POST["TheNewData"]);
}
$stmt->execute();
echo 'Data has been saved<br> <a href="Editor.php" class="button">Editor</a><a> </a><a href="Viewer.php" class="button">Viewer</a>';
}
//echo $_POST["TheNewData"]
?>