big update casadoc
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
// Mostra errori per il debug
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 1);
|
||||
error_reporting(E_ALL);
|
||||
|
||||
include('include/headscript.php');
|
||||
|
||||
// Connessione al database
|
||||
$conn = new mysqli($servername, $username, $password, $database);
|
||||
|
||||
if ($conn->connect_error) {
|
||||
die("Errore di connessione: " . $conn->connect_error);
|
||||
}
|
||||
|
||||
// Controlla se il metodo della richiesta è POST
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
// Recupera i dati dal form
|
||||
$idsections = isset($_POST['idsections']) ? (int)$_POST['idsections'] : 0;
|
||||
$section_name = $conn->real_escape_string($_POST['section_name']);
|
||||
$description = $conn->real_escape_string($_POST['description']);
|
||||
|
||||
// Prepara la query di aggiornamento
|
||||
$query = "UPDATE sections SET section_name = ?, description = ? WHERE idsections = ?";
|
||||
$stmt = $conn->prepare($query);
|
||||
|
||||
if ($stmt === false) {
|
||||
die("Errore nella preparazione della query: " . $conn->error);
|
||||
}
|
||||
|
||||
// Associa i parametri alla query
|
||||
$stmt->bind_param('ssi', $section_name, $description, $idsections);
|
||||
|
||||
// Esegue la query
|
||||
if ($stmt->execute()) {
|
||||
// Reindirizza alla pagina sections.php con un messaggio di successo
|
||||
header("Location: sections.php?success=1");
|
||||
exit();
|
||||
} else {
|
||||
// Reindirizza alla pagina sections.php con un messaggio di errore
|
||||
header("Location: sections.php?error=1");
|
||||
exit();
|
||||
}
|
||||
|
||||
$stmt->close();
|
||||
} else {
|
||||
// Metodo non consentito
|
||||
header("HTTP/1.1 405 Method Not Allowed");
|
||||
echo "Metodo non consentito.";
|
||||
exit();
|
||||
}
|
||||
|
||||
$conn->close();
|
||||
Reference in New Issue
Block a user