<!-- Author  Artūrs Mūrnieks
Created 19.02.2024
Editor Raivis
Modified 19.03.2024 -->
<?php require_once "./ctrluserctrl.php"; ?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Sign Up</title>
    <!-- Include Bootstrap CSS -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous">
</head>
<body>
    <div class="container mt-5">
        <div class="row justify-content-center">
            <div class="col-md-6">
                <div class="card">
                    <div class="card-header bg-success text-white">
                        Sign Up
                    </div>
                    <div class="card-body">
                        <form action="signup.php" method="POST" autocomplete="">
                            <?php
                                if(count($errors) == 1){
                                    ?>
                                    <div class="alert alert-danger text-center">
                                    <?php
                                        foreach($errors as $showerror){
                                            echo $showerror;
                                        }
                                        ?>
                                    </div>
                                    <?php
                                }elseif(count($errors) > 1){
                                    ?>
                                    <div class="alert alert-danger">
                                        <?php
                                        foreach($errors as $showerror){
                                            ?>
                                            <li><?php echo $showerror; ?></li>
                                            <?php
                                        }
                                        ?>
                                    </div>
                                    <?php
                                    }
                                ?>
                            <div class="mb-3">
                                <label for="username" class="form-label">Username</label>
                                <input type="text" class="form-control" id="username" name="username" required value="<?php echo isset($username) ? $username : '' ?>">
                            </div>
                            <div class="mb-3">
                                <label for="password" class="form-label">Password</label>
                                <input type="password" class="form-control" id="password" name="password" required>
                            </div>
                            <div class="mb-3">
                                <label for="cpassword" class="form-label">Confirm Password</label>
                                <input type="password" class="form-control" id="cpassword" name="cpassword" required>
                            </div>
                            <div class="d-grid gap-2">
                                <button type="submit" class="btn btn-success" name="signup">Sign Up</button>
                            </div>
                        </form>
                    </div>
                    <div class="card-footer text-muted">
                        <p class="d-flex mb-0 justify-content-center">Already have an account: <a href="login.php" class="text-success">Login</a></p>
                    </div>
                </div>
            </div>
        </div>
    </div>
</body>
</html>
