I have the following code. I need the variable "$computerID" from the form and the variable "hardwareComputerName". I tested some things, but nothing worked. The variable "$computerID" is no problem.
The form:
<form id="computerRenameForm" action="computerRename" method="post">
<input type="hidden" name="rename" value="">
<input type="hidden" name="computerID" value="<?= htmlspecialchars($computer->id) ?>">
</form>
<button onclick="confirmComputerRename()"><i class="bi bi-trash-fill"></i> Umbenennen</button>
<script>
function confirmComputerRename()
{
(async () => {
const { value: hardwareComputerName } = await Swal.fire({
html: "Zum Umbenennen muss der Computer online sein.<br>Das Gerät wird neu gestartet.",
icon: 'warning',
input: 'text',
inputAttributes: {maxlength: 15},
showCancelButton: true,
confirmButtonText: 'OK',
confirmButtonColor: '#ff0000',
cancelButtonText: 'Abbrechen',
reverseButtons: false
})
if (hardwareComputerName) {
document.getElementById("computerRenameForm").submit();
}
})()
}
</script>
The Controller:
<?php
if (isset($_POST['rename'])) {
$computerID = $_POST['computerID'];
$hardwareComputerName = $_POST['hardwareComputerName'];
var_dump($computerID)."<br>"; // Works
var_dump($hardwareComputerName); // Works not
}
?>