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


<?php
header('Content-Type: text/html; charset=utf-8');
include('config.php');
session_start();

if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $username = trim($_POST['username']);
    $password = trim($_POST['password']);

    $stmt = $bd->prepare("SELECT id FROM admin WHERE username = ? AND passcode = ?");
    if ($stmt) {
        $stmt->bind_param("ss", $username, $password);
        $stmt->execute();

        // Αντικατάσταση get_result με bind_result
        $stmt->store_result();
        if ($stmt->num_rows === 1) {
            $stmt->bind_result($id);
            $stmt->fetch();

            $_SESSION['login_user'] = $username;
            header("Location: home.php");
            exit;
        } else {
            echo "<p style='color:red;'>ΑΠΟΤΥΧΙΑ ΣΥΝΔΕΣΗΣ/ΛΑΘΟΣ ΚΩΔΙΚΟΣ!!! ΠΡΟΣΠΑΘΗΣΤΕ ΠΑΛΙ.</p>";
        }
        $stmt->close();
    } else {
        echo "<p style='color:red;'>Query failed: " . $bd->error . "</p>";
    }
}
?><style>
  h2 .red-text {
    color: black;
  }
</style>

<? include("style.php") ?>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<p>&nbsp;</p>
<title>DYPA application</title>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>


<table border="0" align="center" bgcolor="#555999" >
  
  
    <td width="300" valign="top"  >
      
  
   
<h1 align="center" class="style8"><? echo $hotel ?> hotel</h1> 
   <h1 align="center" class="style8">ΔΥΠΑ(Σ) 24-25 6 ημερες</h1>  
 <h4 align="center" class="style11">(προτεινόμενη χρήση με Google Chrome)</h4>
      <table width="280" border="0" align="center">
        
        <form action="" method="post" class="style1" >
        <tr class="style1">
          
          <td width="140"><input type="text" name="username" size="20" class="inputs" placeholder="Όνομα" required>          </td>
        </tr>              
		<tr class="style1">
          
          <td><input type="password" name="password" size="20" class="inputs" placeholder="password"required>          </td>
    
        
      </table>     <p>&nbsp;</p> 
        <div align="center">
          <input type="submit" 
          name="submit" class="inputsbt" value="Είσοδος" />
        </div></td>


<p>&nbsp;</p>