<?php
//ini_set('display_errors', '1');
//ini_set('display_startup_errors', '1');
//error_reporting(E_ALL);

// Configurazione per la connessione al database
$servername = "172.16.65.81"; 
$username = "underconstruction"; 
$password = "ieX8KVUhe6r7SBNqY8qO"; 
$dbname = "underconstruction"; 
$table_name = "info_siti";

$default = "default";


// Connessione al database
$conn = new mysqli($servername, $username, $password, $dbname);

// Verifica della connessione
if ($conn->connect_error) {
    die("Connessione fallita: " . $conn->connect_error);
}

$stmt = $conn->prepare("SELECT * FROM info_siti WHERE dominio = ?");

$dominio = $_SERVER['HTTP_HOST'];

// Collegamento del parametro con la prepared statement
$stmt->bind_param("s", $dominio);

// Esecuzione della query
$stmt->execute();

// Ottieni il risultato della query
$result = $stmt->get_result();


if ($result->num_rows == 0) {

	$stmt->bind_param("s", $default);
	$stmt->execute();
	$result = $stmt->get_result();
}
		
// Chiudi la prepared statement e la connessione
$stmt->close();
$conn->close();

?>

<!DOCTYPE html>
<html>
<head>
  <title>Sito in costruzione</title>
<meta charset="UTF-8">  
<style>
    body {
      font-family: Arial, sans-serif;
      text-align: center;
      padding: 100px;
      background-color: #4eb5ed;
      color: white;
    }

    h1 {
      font-size: 36px;
      margin-bottom: 30px;
    }

    p {
      font-size: 24px;
      margin-bottom: 20px;
    }

  </style>
</head>
<body>
  <div id="principale">
    <h1>Il sito <?php echo htmlspecialchars($_SERVER['HTTP_HOST']) ;?> è in costruzione</h1>
    <p>Stiamo lavorando duramente per rendere il sito disponibile al più presto.</p>
    <p>Torneremo online a breve. Grazie per la pazienza!</p>
    <img src='img/uc.gif'/>
  </div>

        <?php
        while($row = $result->fetch_assoc()) {
           
            if ($row['email'] != NULL){
                echo "<p>EMAIL: ". $row['email'] . "</p>";
            }
            if ($row['telefono'] != NULL){
                echo "<p>NUMERO DI TELEFONO: ". $row['telefono'] . "</p>";
            }
            if ($row['note'] != NULL){
                echo "<p>". $row['note'] . "</p>";
            }

        }   
        
        ?>


</body>
</html>


