<?php
/*
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

if (!defined('NICKELBOX')) {
    die("Direct access denied.");
}
?>

<div class="container mt-4">
    <div class="row justify-content-center">
        <form class="card" action="action.php" method="post">
            <input type="hidden" name="action" value="signup" />
            <div class="card-header">
                Create Account
            </div>
            <div class="card-body">
                <?php
                $alert = "";
                if (!empty($_GET['msg'])) {
                    switch ($_GET['msg']) {
                        case "badlogin":
                            $alert = "Bad email or password.";
                            break;
                        case "invalidemail":
                            $alert = "Invalid email address.";
                            break;
                    }
                }
                if ($alert != "") {
                    ?>
                <div class="text-danger mb-2">
                    <?php echo $alert; ?>
                </div>
                <?php
                }
                ?>
                <p class="small"><a href="./?page=login">Already have an account?  Click here</a></p>
                <input type="text" name="name" class="form-control mb-2" placeholder="Name" required />
                <input type="email" name="email" class="form-control mb-2" placeholder="Email address" required />
                <input type="password" name="password" class="form-control mb-2" placeholder="Password" required />
                <input type="phone" name="phone" class="form-control" placeholder="Phone (optional)" />
            </div>
            <div class="card-footer d-flex">
                <a href="./" class="btn btn-default">Back</a>
                <button type="submit" class="btn btn-primary ml-auto">Create Account</button>
            </div>
        </form>
    </div>
</div>