59 lines
1.4 KiB
PHP
59 lines
1.4 KiB
PHP
<?php
|
|
session_start();
|
|
include "koneksi.php";
|
|
|
|
if (!isset($_SESSION['user_id'])) {
|
|
header("Location: loginn.php");
|
|
exit;
|
|
}
|
|
|
|
// Selalu ambil saldo dari DATABASE
|
|
$query = "SELECT bank FROM users WHERE id = ?";
|
|
$stmt = mysqli_prepare($conn, $query);
|
|
mysqli_stmt_bind_param($stmt, "i", $_SESSION['user_id']);
|
|
mysqli_stmt_execute($stmt);
|
|
$result = mysqli_stmt_get_result($stmt);
|
|
$data = mysqli_fetch_assoc($result);
|
|
|
|
$currentBank = intval($data["bank"]);
|
|
$_SESSION["bank"] = $currentBank;
|
|
?>
|
|
|
|
<!doctype html>
|
|
<html lang="id">
|
|
<head>
|
|
<meta charset="utf-8" />
|
|
<link rel="stylesheet" href="login.css">
|
|
<title>Top Up</title>
|
|
</head>
|
|
<body>
|
|
|
|
<h2>Top Up Saldo</h2>
|
|
|
|
<p>User: <b><?= $_SESSION['username'] ?></b></p>
|
|
<p>Saldo Bank Sekarang: <b>Rp <?= number_format($currentBank, 0, ',', '.') ?></b></p>
|
|
|
|
<?php if ($message): ?>
|
|
<div style="color:<?= $message_type == 'success' ? 'lime' : 'red' ?>;">
|
|
<?= $message ?>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<form method="POST">
|
|
<label>Pilih Bank :</label><br>
|
|
<input type="radio" name="bank_method" value="bca">BCA<br>
|
|
<input type="radio" name="bank_method" value="bni">BNI<br>
|
|
<input type="radio" name="bank_method" value="mandiri">Mandiri<br><br>
|
|
|
|
<label>Jumlah Top Up:</label>
|
|
<input type="number" name="amount" required><br><br>
|
|
|
|
<button type="submit">Top Up</button>
|
|
</form>
|
|
|
|
<br>
|
|
<a href="html.php">Kembali</a>
|
|
|
|
</body>
|
|
</html>
|