note 130066 added to configuration
| From: | m.bobens@htlkrems.at | Date: | Fri, 28 Feb 2025 09:34:48 +0000 |
| Subject: | note 130066 added to configuration | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-221893@lists.php.net to get a copy of this message | ||
<?php
session_start();
// Datenbankverbindung
$servername = "mysql";
$username = "root";
$password = "htlkrems";
try {
$conn = new PDO("mysql:host=$servername;dbname=classicmodels", $username, $password);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch(PDOException $e) {
echo "Connection failed: " . $e->getMessage();
}
// Suchvariable initialisieren
$inputText = isset($_POST['inp']) ? $_POST['inp'] : '';
// SQL-Abfrage vorbereiten
if (!empty($inputText)) {
$stmt = $conn->prepare("SELECT * FROM offices WHERE city LIKE :inputText");
$inputText .= '%'; // Für LIKE-Anweisung
$stmt->bindParam(':inputText', $inputText);
$stmt->execute();
} else {
$stmt = $conn->query("SELECT * FROM offices");
}
// Datensätze abrufen
$result = $stmt->fetchAll(PDO::FETCH_ASSOC);
$_SESSION['res'] = $result;
// Löschen-Funktion
if (isset($_GET['del']) && is_array($_GET['del'])) {
foreach ($_GET['del'] as $ele) {
$conn->query("UPDATE customers SET salesRepEmployeeNumber = NULL WHERE
salesRepEmployeeNumber IN
(SELECT employeeNumber FROM employees WHERE officeCode = $ele)");
$conn->query("UPDATE employees e JOIN (SELECT employeeNumber FROM employees WHERE
officeCode = $ele) sub
ON e.reportsTo = sub.employeeNumber
SET e.reportsTo = NULL");
$conn->query("DELETE FROM employees WHERE officeCode LIKE '$ele'");
$conn->query("DELETE FROM offices WHERE officeCode LIKE '$ele'");
echo '<meta http-equiv="refresh"
content="2;url=index.php">';
}
}
?>
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Offices</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css"
rel="stylesheet">
</head>
<body>
<div class="container">
<h1>Offices</h1>
<!-- Suchleiste -->
<form method="post" class="mb-3">
<div class="input-group">
<input type="text" name="inp" class="form-control"
placeholder="Stadt eingeben" value="<?=
htmlspecialchars(isset($_POST['inp']) ? $_POST['inp'] : '')
?>">
<button type="submit" class="btn
btn-success">Suchen</button>
</div>
</form>
<!-- A-Z Buttons -->
<form method="post" class="mb-3">
<?php
foreach (range('A', 'Z') as $char) {
echo "<button type='submit' name='inp'
value='$char' class='btn btn-primary m-1'>$char</button>";
}
?>
</form>
<!-- Tabelle für die Ergebnisse -->
<form method="GET" action="index.php">
<table class="table">
<thead>
<tr>
<th>City</th>
<th>Phone</th>
<th>AdressLine1</th>
<th>Country</th>
<th>PostalCode</th>
<th>Territory</th>
<th>Löschen</th>
</tr>
</thead>
<tbody>
<?php foreach ($result as $row): ?>
<tr>
<td><?= htmlspecialchars($row['city']) ?></td>
<td><?= htmlspecialchars($row['phone']) ?></td>
<td><?= htmlspecialchars($row['addressLine1'])
?></td>
<td><?= htmlspecialchars($row['country'])
?></td>
<td><?= htmlspecialchars($row['postalCode'])
?></td>
<td><?= htmlspecialchars($row['territory'])
?></td>
<td><input type="checkbox" name="del[]"
value="<?= htmlspecialchars($row['officeCode']) ?>"></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<button type="submit" class="btn
btn-danger">Löschen</button>
</form>
</div>
</body>
</html>
----
Server IP: 45.112.84.4
Probable Submitter: 80.90.5.137 (proxied: 193.170.70.27)
----
Manual Page -- https://php.net/manual/en/configuration.php
Edit -- https://main.php.net/note/edit/130066
Del: integrated -- https://main.php.net/note/delete/130066/integrated
Del: useless -- https://main.php.net/note/delete/130066/useless
Del: bad code -- https://main.php.net/note/delete/130066/bad+code
Del: spam -- https://main.php.net/note/delete/130066/spam
Del: non-english -- https://main.php.net/note/delete/130066/non-english
Del: in docs -- https://main.php.net/note/delete/130066/in+docs
Del: other reasons-- https://main.php.net/note/delete/130066
Reject -- https://main.php.net/note/reject/130066
Search -- https://main.php.net/manage/user-notes.php