} catch (PDOException $e) {
    print 'Connection failed: ' . $e->getMessage();
}
?>
<body>
<main>
    <h1>Hunting Style Edit</h1>
    <div>
        <h2>Add new creature hunting style</h2>
        <form method="post" action="CreatureHuntingStyleAdd.php">
            <input type="text" name="Name">
            <input type="submit" value="Create">
            <input type="reset" value="Restart">
        </form>
    </div>
    <div>
        <h2>List of creature hunting styles</h2>
        <ul>
            <?php 
$creatureHuntingStyleGateway = new CreatureHuntingStyleGateway($database);
$attributes = $creatureHuntingStyleGateway->selectAll();
foreach ($attributes as $attribute) {
    print "<li>" . $attribute['name'] . "</li>";
}
?>
        </ul>
    </div>
</main>
</body>
</html>
<?php

use BattleChores\domain\creature\CreatureHuntingStyleGateway;
include '../config.php';
try {
    $database = new PDO($dsn, $user, $password);
} catch (PDOException $e) {
    print 'Connection failed: ' . $e->getMessage();
}
$errorCount = 0;
if (!isset($_POST['Name']) || strlen($_POST['Name']) < 1) {
    print "<p>Please specify a name for the creature hunting style</p>";
    $errorCount++;
}
if (strlen($_POST['Name']) > 50) {
    print "<p>The creature hunting style's name must be shorter than 50 characters</p>";
    $errorCount++;
}
if ($errorCount == 0) {
    $creatureHuntingStyleGateway = new CreatureHuntingStyleGateway($database);
    $insertSuccess = $creatureHuntingStyleGateway->insertNew($_POST['Name']);
    if ($insertSuccess) {
        print "Hunting Style " . $_POST['Name'] . " successfully added to the Database";
    } else {
        print "Error Adding hunting style " . $_POST['Name'];
    }
}