<?php
include_once 'include/controller.php';
?>

<!DOCTYPE html>
<html lang="fr">
    <head>
        <meta charset="UTF-8" />
        <title>Exercice 3</title>
        <link
          rel="stylesheet"
          href="https://cdn.jsdelivr.net/npm/@picocss/pico.min.css"
        />
        <link rel="stylesheet" href="./css/style.css">
    </head>
    <body>
        <main class="container">
            <h3>Calculatrice</h3>
            <form method="POST">
                <div class="grid">
                    <input
                        placeholder="un nombre"
                        type="number"
                        step="any"
                        name="op1"
                        value="<?php echo htmlspecialchars($valeurOp1, ENT_QUOTES, 'UTF-8'); ?>"
                        required
                    >
                    <select name="operation" required>
                        <option value="+" <?php echo $operation === '+' ? 'selected' : ''; ?>>+</option>
                        <option value="-" <?php echo $operation === '-' ? 'selected' : ''; ?>>-</option>
                        <option value="x" <?php echo $operation === 'x' ? 'selected' : ''; ?>>x</option>
                        <option value="/" <?php echo $operation === '/' ? 'selected' : ''; ?>>/</option>
                    </select>
                    <input
                        placeholder="un nombre"
                        type="number"
                        step="any"
                        name="op2"
                        value="<?php echo htmlspecialchars($valeurOp2, ENT_QUOTES, 'UTF-8'); ?>"
                        required
                    >
                    <button type="submit" name="soumis">Calculer</button>
                </div>
            </form>

            <?php if ($messageErreur !== '') : ?>
                <p><?php echo htmlspecialchars($messageErreur, ENT_QUOTES, 'UTF-8'); ?></p>
            <?php endif; ?>

            <?php if ($aCalcule) : ?>
                <p>
                    RÃ©sultat :
                    <?php echo htmlspecialchars($valeurOp1, ENT_QUOTES, 'UTF-8'); ?>
                </p>
            <?php endif; ?>
        </main>
    </body>
</html>
