DK2/templates/pages/home.php

33 lines
1.2 KiB
PHP
Raw Normal View History

<?php if (!user()): ?>
<h2>Welcome!</h2>
2024-09-27 18:45:33 -05:00
<a href="/auth/register">Register</a>
<a href="/auth/login">Login</a>
<?php else: ?>
<h2>Hello, <?= user('username') ?>!</h2>
<?php if (user('char_id') !== 0): ?>
<h3>Playing as <?= char_find(user('char_id'))['name'] ?></h3>
<?php endif; ?>
2024-09-27 18:45:33 -05:00
<form action="/auth/logout" method="post">
<input type="hidden" name="csrf" value="<?= csrf() ?>">
<input type="submit" value="Logout">
</form>
<?php if (char_count(user('id')) > 0): ?>
<h3>Characters</h3>
<form action="character/select" method="post">
<input type="hidden" name="csrf" value="<?= csrf() ?>">
<?php foreach (char_list(user('id')) as $id => $char): ?>
<input type="radio" name="char_id" value="<?= $id ?>" id="char_<?= $id ?>">
<label for="char_<?= $id ?>"><?= $char['name'] ?> (Level <?= $char['level'] ?>)</label><br>
<?php endforeach; ?>
<input type="submit" value="Select Character">
</form>
<?php endif; ?>
<form action="/character/create" method="post">
<input type="hidden" name="csrf" value="<?= csrf() ?>">
<input type="text" name="name" placeholder="Character Name">
<input type="submit" value="Create Character">
</form>
2024-09-27 18:45:33 -05:00
<?php endif; ?>