48 lines
1.4 KiB
PHP
48 lines
1.4 KiB
PHP
<?php
|
|
require_once "../includes/config.php";
|
|
if ($_SERVER["REQUEST_METHOD"] === "POST") {
|
|
$username = trim($_POST["username"]);
|
|
$password = password_hash($_POST["password"], PASSWORD_DEFAULT);
|
|
|
|
// Insert using prepared statement (safe)
|
|
$stmt = $conn->prepare("INSERT INTO users (username, password) VALUES (?, ?)");
|
|
$stmt->bind_param("ss", $username, $password);
|
|
|
|
if ($stmt->execute()) {
|
|
echo "Account created! <a href='login.php'>Login here</a>";
|
|
exit;
|
|
} else {
|
|
echo "Username already exists.";
|
|
}
|
|
}
|
|
?>
|
|
|
|
<!doctype html>
|
|
<html lang="id">
|
|
<head>
|
|
<meta charset="utf-8" />
|
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
<title>Hit or Run — Sign Up</title>
|
|
<link rel="stylesheet" href="assets/css/style.css">
|
|
</head>
|
|
<body>
|
|
<div class="card">
|
|
<div class="logo">🂡</div>
|
|
<h2>Hit or Run</h2>
|
|
|
|
<?php if (!empty($error)) echo "<p style='color:red;'>$error</p>"; ?>
|
|
|
|
<form action="" method="post">
|
|
<label>Username</label>
|
|
<input type="text" placeholder="Masukkan username" />
|
|
|
|
<label>Password</label>
|
|
<input type="password" placeholder="Masukkan password" />
|
|
|
|
<button type="submit">Sign Up</button>
|
|
</form>
|
|
|
|
<div class="note">Sudah punya akun? <a href="signin.html">Sign In!</a></div>
|
|
</div>
|
|
</body>
|
|
</html>
|