<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
require_once '../models/db_connection.php';
require_once '../models/user_model.php';
$user = new User($conn);
if (isset($_POST["register"])) {
  $username = $_POST["username"];
  $email = $_POST['email'];
  $password = $_POST["password"];
  $password1 = $_POST["verifyPassword"];
  if ($password == $password1) {
    $success =  $user->register($username, $password, $email);
    header("Location: ../user/all_users.php?message=User Registered successfully");
    exit(); // Stop further execution
  }
}
?>
<!DOCTYPE html>
<html lang="en">

<head>
  <!-- Required meta tags -->
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  <title>Regal Admin</title>
  <?php include("../templates/header.php"); ?>
</head>

<body>
  <div class="container-scroller">
    <div class="container-fluid page-body-wrapper full-page-wrapper">
      <div class="content-wrapper d-flex align-items-center auth px-0">
        <div class="row w-100 mx-0">
          <div class="col-lg-4 mx-auto">
            <div class="auth-form-light text-left py-5 px-4 px-sm-5">

              <h4>Registration Form</h4>
              <h6 class="font-weight-light">Register a new account</h6>
              <form class="pt-3" method="POST" action="register.php">
                <div class="form-group">
                  <input type="text" class="form-control form-control-lg" id="exampleInputUsername1" placeholder="Username" name="username" required>
                </div>
                <div class="form-group">
                  <input type="email" class="form-control form-control-lg" id="exampleInputUsername1" placeholder="Email" name="email" required>
                </div>
                <div class="form-group">
                  <input type="password" class="form-control form-control-lg" id="exampleInputEmail1" placeholder="Password" name="password" required>
                </div>
                <div class="form-group">
                  <input type="password" class="form-control form-control-lg" id="exampleInputPassword1" placeholder="Verify Password" name="verifyPassword" required>
                </div>
                <div class="mb-4">

                </div>
                <div class="mt-3">
                  <button class="btn btn-block btn-info btn-lg font-weight-medium auth-form-btn" type='submit' name="register">SIGN UP</button>
                </div>

              </form>
            </div>
          </div>
        </div>
      </div>
      <!-- content-wrapper ends -->
    </div>
    <!-- page-body-wrapper ends -->
  </div>
  <?php include("../templates/inc_scripts.php"); ?>
</body>

</html>