ppeasy/public/deletephotoone.php

35 lines
1.0 KiB
PHP

<?php
require_once('../Connections/cmctrfdb.php'); // Database connection
if (isset($_GET['idtrf']) && is_numeric($_GET['idtrf'])) {
$idtrf = intval($_GET['idtrf']);
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
die("Connessione al database fallita: " . $conn->connect_error);
}
// Esegui l'aggiornamento per impostare photoone a NULL
$query = "UPDATE `trf-details` SET photoone = NULL WHERE idtrfdetails = ?";
$stmt = $conn->prepare($query);
$stmt->bind_param("i", $idtrf);
$stmt->execute();
if ($stmt->affected_rows > 0) {
error_log("Successfully updated photoone to NULL for idtrfdetails = $idtrf");
} else {
error_log("Failed to update photoone for idtrfdetails = $idtrf");
}
$stmt->close();
$conn->close();
// Reindirizza alla pagina principale
header("Location: adddocument.php?idtrf=$idtrf&t=" . time());
exit;
} else {
// Se idtrf non è valido, reindirizza
header("Location: index.php");
exit;
}