diff --git a/koneksi.php b/koneksi.php
index f1df661..7f94225 100644
--- a/koneksi.php
+++ b/koneksi.php
@@ -9,4 +9,10 @@ $conn = mysqli_connect($host, $user, $pass, $db);
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
+// Ensure 'balance' column exists in 'users' table. If not, add it with default 0.
+$check = mysqli_query($conn, "SHOW COLUMNS FROM users LIKE 'balance'");
+if ($check && mysqli_num_rows($check) == 0) {
+ // Attempt to add the column; ignore errors if table doesn't exist yet.
+ @mysqli_query($conn, "ALTER TABLE users ADD COLUMN balance INT NOT NULL DEFAULT 0");
+}
?>
diff --git a/loginn.php b/loginn.php
index 89fcf85..f0ff8c6 100644
--- a/loginn.php
+++ b/loginn.php
@@ -9,7 +9,12 @@ if(isset($_POST['login'])){
$result = mysqli_query($conn, $sql);
if (mysqli_num_rows($result) > 0) {
- header("Location: html.php" );
+ $user = mysqli_fetch_assoc($result);
+ session_start();
+ $_SESSION['username'] = $user['username'];
+ // ensure balance key exists
+ $_SESSION['balance'] = isset($user['balance']) ? (int)$user['balance'] : 0;
+ header("Location: html.php");
exit;
} else {
$error = 'Invalid username or password.';
diff --git a/logout.php b/logout.php
new file mode 100644
index 0000000..3f7b77d
--- /dev/null
+++ b/logout.php
@@ -0,0 +1,7 @@
+
diff --git a/register.php b/register.php
index 1bc8bcd..6831756 100644
--- a/register.php
+++ b/register.php
@@ -7,7 +7,12 @@ if (isset($_POST['register'])) {
$username = $_POST['username'];
$password = $_POST['password'];
- $SQL = "INSERT INTO users (username, password) VALUES ('$username', '$password')";
+ // basic escaping to avoid simple injection (keep consistent with existing style)
+ $username = mysqli_real_escape_string($conn, $username);
+ $password = mysqli_real_escape_string($conn, $password);
+
+ // insert with initial balance = 0
+ $SQL = "INSERT INTO users (username, password, balance) VALUES ('$username', '$password', 0)";
$result = mysqli_query($conn, $SQL);
if ($result) {
diff --git a/topup.php b/topup.php
new file mode 100644
index 0000000..8ce1c69
--- /dev/null
+++ b/topup.php
@@ -0,0 +1,66 @@
+ 0) {
+ $row = mysqli_fetch_assoc($res);
+ $_SESSION['balance'] = (int)$row['balance'];
+ $message = 'Top up berhasil. Saldo sekarang: ' . $_SESSION['balance'];
+ } else {
+ $message = 'Top up berhasil, tetapi gagal mengambil saldo terbaru.';
+ }
+ } else {
+ $message = 'Gagal memproses top up. Coba lagi.';
+ }
+ }
+}
+?>
+
+
+
+
+
+
+
Top Up - OCA GameHub
+
+
+
+
+
Top Up Saldo
+
Pengguna:
+
Saldo saat ini:
+
+
+
+
+
+
+
+
+