Das folgende Beispiel funktioniert:
[src=php]<<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Test Page</title>
</head>
<body>
<?php
print_r($_GET);
if (isset($_GET['rename']) && isset($_GET['to'])) {
echo 'inside!';
die();
}
?>
<script type="text/javascript">
window.location.href = "test.php?rename=1&to=NewOne"
</script>
</body>
</html>[/src]
Was nicht funktioniert, hier alles was im [kw]script-Tag[/kw] enthalten ist.
[src=php]<!DOCTYPE html>
<html>
<head>
<title>sqStorage</title>
<link rel="stylesheet" href="./css/bootstrap/bootstrap.css">
<link rel="stylesheet" href="./css/base.css">
<link rel="stylesheet" href="./fonts/fontawesome/css/solid.css">
<link rel="stylesheet" href="./fonts/fontawesome/css/regular.css">
<link rel="stylesheet" href="./fonts/fontawesome/css/fontawesome.css">
<meta charset="utf-8">
</head> <body>
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<a href="index.php"><img class="logo" src="./img/sqstorage.png" /></a>
<ul class="nav">
<li class="nav-item"><a href="index.php" class="nav-link">Eintragen</a></li>
<li class="nav-item"><a href="inventory.php" class="nav-link">Inventar</a></li>
<li class="nav-item"><a href="categories.php" class="nav-link">Kategorien</a></li>
</ul>
<form class="form-inline my-2 " method="GET" action="inventory.php">
<input class="form-control mr-sm-2" name="searchValue" type="search" placeholder="Suche" aria-label="Suche">
<button class="btn btn-outline-success my-2 my-sm-0" type="submit">Suchen</button>
</form>
</nav>
<div class="content">
<hr/><ul class="categories list-group"><li class="alert alert-info"><span class="list-span">Kategorien</span><span class="list-span">Anzahl</span><span class="list-span">Aktionen</span></li><li class="list-group-item"><a name="removeCategory" data-name="Netzwerk2" href="categories.php?removeCategory=4" class="removalButton fas fa-times-circle btn"></a><a class="list-span" data-name="Netzwerk2" href="inventory.php?category=4">Netzwerk2</a><span class="list-span">1 Gegenstand</span><a class="fas fa-edit editCategory" href="categories.php" name="editCategory" data-name="Netzwerk2" data-id="4"></a></li><li class="list-group-item"><a name="removeCategory" data-name="Netzwerk3" href="categories.php?removeCategory=5" class="removalButton fas fa-times-circle btn"></a><a class="list-span" data-name="Netzwerk3" href="inventory.php?category=5">Netzwerk3</a><span class="list-span">3 Gegenstände</span><a class="fas fa-edit editCategory" href="categories.php" name="editCategory" data-name="Netzwerk3" data-id="5"></a></li></ul><hr/><ul class="categories list-group"><li class="alert alert-info"><span class="list-span">Unterkategorien</span><span class="list-span">Anzahl</span><span class="list-span">Aktionen</span></li></ul> </div>
<script type="text/javascript">
let removalButtons = document.querySelectorAll('.removalButton')
for (let button of removalButtons) {
button.addEventListener('click', function (evt) {
let targetType = evt.target.name === 'removeCategory' ? 'Kategorie wirklich entfernen?' : 'Unterkategorie wirklich entfernen?'
if (!window.confirm(targetType + ' "' + evt.target.dataset['name'] +'"')) {
evt.preventDefault()
}
})
}
let editCategoryButtons = document.querySelectorAll('.editCategory')
for (let button of editCategoryButtons) {
button.addEventListener('click', function (evt) {
let targetType = evt.target.name === 'editCategory' ? 'Kategorie umbenennen?' : 'Unterkategorie umbenennen?'
let newName = window.prompt(targetType + ' "' + evt.target.dataset['name'] + '"', '')
if (newName !== null && newName.length !== 0) {
if (evt.target.name === 'editCategory') window.location.href = 'categories.php?headCategory=' + evt.target.dataset['id'] + '&to=' + newName
else window.location.href = 'categories.php?subCategory=' + evt.target.dataset['id'] + '&to=' + newName
return false
}
evt.preventDefault()
return false
})
}
</script>
</body>
</html>[/src]
Screenshot des Aufrufs:
Edit: Noch ein Nachtrag, auch wenn ich ein "die()" einfüge, der $_GET Parameter ist leer. Auch wenn die URL wie im Screenshot aufgerufen wird.
Hier ein Screenshot dazu:
$_SERVER, $_GET, $_POST (letzten zwei sind leere Arrays.