} catch (PDOException $e) {
    print 'Connection failed: ' . $e->getMessage();
}
?>
<body>
<main>
    <h1>Creature Social Type Edit</h1>
    <div>
        <h2>Add new creature social type </h2>
        <form method="post" action="CreatureSocialAdd.php">
            <input type="text" name="Name">
            <input type="submit" value="Create">
            <input type="reset" value="Restart">
        </form>
    </div>
    <div>
        <h2>List of Creature Social Types</h2>
        <ul>
            <?php 
$creatureSocialGateway = new CreatureSocialGateway($database);
$attributes = $creatureSocialGateway->selectAll();
foreach ($attributes as $attribute) {
    print "<li>" . $attribute['name'] . "</li>";
}
?>
        </ul>
    </div>
</main>
</body>
</html>
<?php

use BattleChores\domain\creature\CreatureSocialGateway;
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 social type</p>";
    $errorCount++;
}
if (strlen($_POST['Name']) > 50) {
    print "<p>The creature social type's name must be shorter than 50 characters</p>";
    $errorCount++;
}
if ($errorCount == 0) {
    $creatureSocialGateway = new CreatureSocialGateway($database);
    $insertSuccess = $creatureSocialGateway->insertNew($_POST['Name']);
    if ($insertSuccess) {
        print "Social type " . $_POST['Name'] . " successfully added to the Database";
    } else {
        print "Error Adding social type " . $_POST['Name'];
    }
}