refisi update
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
require 'db.php';
|
||||
|
||||
$message = "";
|
||||
|
||||
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||
$username = $_POST['username'];
|
||||
$password = password_hash($_POST['password'], PASSWORD_DEFAULT);
|
||||
|
||||
$check = $conn->query("SELECT * FROM users WHERE username='$username'");
|
||||
if ($check->num_rows > 0) {
|
||||
$message = "Username sudah digunakan!";
|
||||
} else {
|
||||
$sql = "INSERT INTO users(username, password) VALUES('$username', '$password')";
|
||||
if ($conn->query($sql)) {
|
||||
header("Location: index.php");
|
||||
exit;
|
||||
} else {
|
||||
$message = "Gagal registrasi!";
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Register</title>
|
||||
<link rel="stylesheet" href="assets/style.css">
|
||||
</head>
|
||||
<body>
|
||||
<div class="box">
|
||||
<h2>Register</h2>
|
||||
<form method="POST">
|
||||
<input type="text" name="username" placeholder="Username" required><br>
|
||||
<input type="password" name="password" placeholder="Password" required><br>
|
||||
<button type="submit">Daftar</button>
|
||||
</form>
|
||||
<p><?= $message ?></p>
|
||||
<a href="index.php">Login</a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user