90 lines
2.3 KiB
PHP
90 lines
2.3 KiB
PHP
<<<<<<< HEAD
|
|
<?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>
|
|
=======
|
|
<?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>
|
|
>>>>>>> 720425e3f38951553731cb9aae9a4c9a34f6c2b4
|