Add List Functions working and changed image-URL

This commit is contained in:
2022-11-25 01:50:02 +01:00
parent 48d3433416
commit 4f8b1d07bc
5 changed files with 116 additions and 15 deletions

View File

@@ -51,6 +51,36 @@ if (isset($_POST['login'])) {
$conn->close();
}
if (isset($_POST['listadd'])) {
$listName = $_POST['listName'];
$listPassword = password_hash($_POST['listPassword'], PASSWORD_DEFAULT);
$listDescription = $_POST['listDescription'];
$conn = new mysqli($servername, $username, $password, $db);
// Check connection
if ($conn->connect_error) {
die('Connection failed: ' . $conn->connect_error);
}
$sql = 'INSERT INTO lists (title, description, edit_pw) VALUES ("' . $listName . '", "' .$listDescription. '","' . $listPassword . '")';
$result = $conn->query($sql);
if ($conn->query($sql) === TRUE) {
$last_id = $conn->insert_id;
$_SESSION['listid'] = $last_id;
$loggedin = true;
$actual_link = 'http://' . $_SERVER['HTTP_HOST'] . '/?list=' . $last_id;
header('Location: ' . $actual_link);
} else {
$message = array('msg' => 'Error: ' . $sql . '<br>' . $conn->error, 'type' => 'error');
}
$conn->close();
}
if (isset($_POST['logout'])) {
session_destroy();
$loggedin = false;
@@ -334,6 +364,7 @@ if (isset($_POST['delete']) && $loggedin == true) {
</div>
</div>
</div>
<!-- END OF Modal Delete-->
');
}
?>
@@ -364,7 +395,7 @@ if (isset($_POST['delete']) && $loggedin == true) {
</div>
</div>
</div>
<!-- END OF Modal Reservation-->
<script>
$('#reservationModal').on('show.bs.modal', function(event) {
@@ -384,21 +415,28 @@ if (isset($_POST['delete']) && $loggedin == true) {
}
});
$('#deleteModal').on('show.bs.modal', function(event) {
var resTr = $(event.relatedTarget)
var whishcard = resTr.parents().closest('.card');
var whishtitle = whishcard.find('.card-title').text();
var wishid = resTr.data('wishid')
var modal = $(this)
modal.find('#WhishID').val(wishid)
modal.find('#whish-title').text(whishtitle)
});
<?php
if ($loggedin == true) {
echo ('
$(\'#deleteModal\').on(\'show.bs.modal\', function(event) \{
var resTr = $(event.relatedTarget)
var whishcard = resTr.parents().closest(\'.card\');
var whishtitle = whishcard.find(\'.card-title\').text();
var wishid = resTr.data(\'wishid\')
var modal = $(this)
modal.find(\'#WhishID\').val(wishid)
modal.find(\'#whish-title\').text(whishtitle)
});
');
}
?>
$(document).ready(function() {
$('#sortby').on('change', function() {
this.form.submit();
});
});
</script>
</body>