<?php
include('include/headscript.php');
$conn = new mysqli($servername, $username, $password, $database);

if ($conn->connect_error) {
    die("Errore di connessione: " . $conn->connect_error);
}

// Recupera i dati dal form
$namepages = $_POST['namepages'];
$slug = $_POST['slug'];
$descriptionpages = $_POST['descriptionpages'];

// Inserisce la nuova pagina nel database
$query = $conn->prepare("INSERT INTO pages (namepages, slug, descriptionpages) VALUES (?, ?, ?)");
$query->bind_param('sss', $namepages, $slug, $descriptionpages);

if ($query->execute()) {
    header("Location: page-settings.php?success=1");
} else {
    header("Location: page-settings.php?error=1");
}

$query->close();
$conn->close();
