51 lines
1.4 KiB
PHP
51 lines
1.4 KiB
PHP
<?php
|
|
require_once 'functions/auth.php';
|
|
|
|
// Redirect ke dashboard jika sudah login
|
|
if(isLoggedIn()) {
|
|
header("Location: dashboard.php");
|
|
exit;
|
|
}
|
|
|
|
$error = '';
|
|
$success = '';
|
|
|
|
if($_SERVER['REQUEST_METHOD'] == 'POST') {
|
|
$username = $_POST['username'];
|
|
$email = $_POST['email'];
|
|
$password = $_POST['password'];
|
|
|
|
$res = registerUser($username, $email, $password);
|
|
if($res['success']) {
|
|
$success = 'Registrasi berhasil! Silahkan Login.';
|
|
} else {
|
|
$error = $res['error'];
|
|
}
|
|
}
|
|
|
|
require_once 'partials/header.php';
|
|
?>
|
|
|
|
<div class="bg-login">
|
|
<?php require_once 'partials/navbar.php'; ?>
|
|
|
|
<div class="auth-container">
|
|
<div class="card auth-card">
|
|
<h2>Register</h2>
|
|
<?php if($error): ?>
|
|
<p class="message msg-error"><?= htmlspecialchars($error) ?></p>
|
|
<?php endif; ?>
|
|
<?php if($success): ?>
|
|
<p class="message msg-success"><?= htmlspecialchars($success) ?></p>
|
|
<?php endif; ?>
|
|
<form method="POST">
|
|
<input type="text" name="username" placeholder="Username" required>
|
|
<input type="email" name="email" placeholder="Email" required>
|
|
<input type="password" name="password" placeholder="Password" required>
|
|
<button type="submit">Register</button>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<?php require_once 'partials/footer.php'; ?>
|