fix: fitur register

This commit is contained in:
Matthew Florentino 2025-11-28 11:45:35 +07:00
parent 267e5d1c38
commit 280f6d0639
2 changed files with 45 additions and 26 deletions

View File

@ -171,13 +171,35 @@
align-content: center; align-content: center;
} }
.container-board table { .container-board .board table {
margin: 0 auto; width: 600px;
margin: 40px auto;
border-collapse: collapse;
/*menghilangkan gap antar border*/
font-family: "Segoe UI", Tahoma, sans-serif;
color: white;
border-radius: 10px; border-radius: 10px;
width: 400px; overflow: hidden;
border: 1px solid; }
height: 40px;
align-content: center; .container-board .board table th,
td {
border: 5px solid #ffffffb8;
padding: 14px 18px;
white-space: nowrap;
text-align: center;
}
.container-board .board table thead th {
font-weight: 400;
font-size: 20px;
color: #bbd000;
letter-spacing: .4px;
}
.container-board .board table tbody tr:hover {
background: #c1fc0032;
} }
.container-onboard { .container-onboard {
@ -192,7 +214,7 @@
background-size: cover; */ background-size: cover; */
} }
.container-onboard h1{ .container-onboard h1 {
font-size: 150px; font-size: 150px;
color: yellow; color: yellow;
font-weight: 400; font-weight: 400;

View File

@ -14,14 +14,14 @@ if(isset($_POST['register'])){
$rpassword = $_POST['rpassword']; $rpassword = $_POST['rpassword'];
if(empty($email) || empty($username) || empty($password)){ if(empty($email) || empty($username) || empty($password)){
$pesan_gagal= "Semua data harus terisi"; $_SESSION['flash'] = "Semua data harus terisi";
}else if($password !== $rpassword){ }else if($password !== $rpassword){
$pesan_gagal= "password tidak sama"; $_SESSION['flash']= "password tidak sama";
} }
else{ else{
$hashpw = password_hash($password, PASSWORD_DEFAULT); $hashpw = password_hash($password, PASSWORD_DEFAULT);
$sql = "INSERT INTO users (email,username,password)VALUES(?,?,?)"; $sql = "INSERT INTO users (email,username,password,score)VALUES(?,?,?,0)";
$stmt = $db -> prepare($sql); $stmt = $db -> prepare($sql);
@ -30,26 +30,14 @@ if(isset($_POST['register'])){
if($stmt->execute()){ if($stmt->execute()){
$new_user_id =$db-> insert_id; header("location:index.php");
exit();
$sql_char = "INSERT INTO users (user_id, name, score) VALUES (?, ?, 0)";
$stmt_char = $db->prepare($sql_char);
$stmt_char->bind_param("is", $new_user_id, $username);
if($stmt_char->execute()){
header("location:index.php");
exit();
}else{
$pesan_gagal = "Registrasi user berhasil, tapi gagal membuat karakter: " . $stmt_char->error;
}
$stmt_char->close();
}else{ }else{
if($stmt->erno==1602){ if($stmt->erno==1602){
$pesan_gagal = "email atau username sudah pernah terdaftar"; $_SESSION['flash'] = "email atau username sudah pernah terdaftar";
}else{ }else{
$pesan_sukses = "Regitrasi gagal: ".$stmt->error; $_SESSION['flash'] = "Regitrasi gagal: ".$stmt->error;
} }
} }
$stmt -> close(); $stmt -> close();
@ -70,6 +58,15 @@ if(isset($_POST['register'])){
</head> </head>
<body> <body>
<div class="container-register"> <div class="container-register">
<?php
include "notif.php";
if (isset($_SESSION['flash'])) {
echo "<script>showNotif(" . json_encode($_SESSION['flash']) . ");</script>";
unset($_SESSION['flash']);
}
?>
<h1 data-aos="zoom-out" data-aos-duration="1000">codebeater</h1> <h1 data-aos="zoom-out" data-aos-duration="1000">codebeater</h1>
<form action="register.php" method="POST"> <form action="register.php" method="POST">
<h2 data-aos="fade-up" data-aos-duration="1000">Register to get account</h2> <h2 data-aos="fade-up" data-aos-duration="1000">Register to get account</h2>