diff --git a/topup.php b/topup.php index 5b2a25a..bdaa868 100644 --- a/topup.php +++ b/topup.php @@ -381,6 +381,13 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { maximumFractionDigits: 0 }); localStorage.setItem('playerBalance', serverBalance); + + $update = "UPDATE users SET bank = ? WHERE id = ?"; + $stmt = mysqli_prepare($conn, $update); + mysqli_stmt_bind_param($stmt, "ii", $newBank, $_SESSION['user_id']); + mysqli_stmt_execute($stmt); + $_SESSION['bank'] = $newBank; + diff --git a/users.sql b/users.sql index 8c14041..0cad9d6 100644 --- a/users.sql +++ b/users.sql @@ -1,95 +1,7 @@ --- phpMyAdmin SQL Dump --- version 5.2.1 --- https://www.phpmyadmin.net/ --- --- Host: 127.0.0.1 --- Generation Time: Dec 01, 2025 at 04:50 AM --- Server version: 10.4.32-MariaDB --- PHP Version: 8.0.30 - -SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; -START TRANSACTION; -SET time_zone = "+00:00"; - - -/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; -/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; -/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; -/*!40101 SET NAMES utf8mb4 */; - --- --- Database: `login` --- - --- -------------------------------------------------------- - --- --- Table structure for table `users` --- - -CREATE TABLE `users` ( - `id` int(11) NOT NULL, - `username` varchar(50) DEFAULT NULL, - `password` varchar(255) DEFAULT NULL -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; - --- --- Dumping data for table `users` --- - -INSERT INTO `users` (`id`, `username`, `password`) VALUES -(1, '', ''), -(15, 'Alex', '123'), -(16, 'Ody', '123'), -(17, 'cliff', '123'); - --- --- Indexes for dumped tables --- - --- --- Indexes for table `users` --- -ALTER TABLE `users` - ADD PRIMARY KEY (`id`), - ADD UNIQUE KEY `username` (`username`); - --- --- AUTO_INCREMENT for dumped tables --- - --- --- AUTO_INCREMENT for table `users` --- -ALTER TABLE `users` - MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=23; -COMMIT; - -/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; -/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; -/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; - --- Tabel users -CREATE TABLE users ( - id INT PRIMARY KEY AUTO_INCREMENT, - username VARCHAR(50) UNIQUE NOT NULL, - password VARCHAR(255) NOT NULL, - balance DECIMAL(10,2) DEFAULT 0.00, - created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP -); - --- Tabel transaction history (opsional) -CREATE TABLE transactions ( - id INT PRIMARY KEY AUTO_INCREMENT, - user_id INT, - type ENUM('topup', 'win', 'loss', 'bet'), - amount DECIMAL(10,2), - description VARCHAR(255), - created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, - FOREIGN KEY (user_id) REFERENCES users(id) -); - -ALTER TABLE users MODIFY COLUMN balance INT DEFAULT 1000; +-- ========================================== +-- FIX: TABLE USERS DENGAN KOLOM BANK +-- BANK TETAP TERSIMPAN SAAT LOGOUT & LOGIN +-- ========================================== DROP TABLE IF EXISTS users; @@ -97,13 +9,14 @@ CREATE TABLE users ( id INT PRIMARY KEY AUTO_INCREMENT, username VARCHAR(50) UNIQUE NOT NULL, password VARCHAR(255) NOT NULL, - - -- saldo yang dipakai oleh game.php - bank INT DEFAULT 1000, - - -- saldo yang dipakai login.php (boleh dipakai atau hapus) - balance INT DEFAULT 1000, - + bank INT DEFAULT 1000, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, last_login TIMESTAMP NULL DEFAULT NULL ); + +-- Tambahin contoh user +INSERT INTO users (username, password, bank) VALUES +('Ody', '123', 1500), +('Claudia', '123', 2000), +('Alex', '123', 1000); +