-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtemplate_transaction
More file actions
56 lines (47 loc) · 1.79 KB
/
Copy pathtemplate_transaction
File metadata and controls
56 lines (47 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
session_start();
$connection = mysqli_connect("localhost", "root", "", "platform");
if (!$connection) {
die("Connection failed: " . mysqli_connect_error());
}
$user_id = $_SESSION['id'];
$user_wallet = "1A2b3C4d5E6f7G8H9i0J"; // Replace with actual user wallet
$recipient_wallet = "3FZbgi29cpjq2GjdwV8eyHuJJnkLtktZc5"; // Replace with actual recipient
$amount_btc = 0.005;
$status = "success"; // Or 'pending', 'failed'
$sql = "INSERT INTO btc_transactions (user_id, user_wallet, recipient_wallet, amount_btc, status)
VALUES ('$user_id', '$user_wallet', '$recipient_wallet', '$amount_btc', '$status')";
if (mysqli_query($connection, $sql)) {
echo "Transaction recorded successfully!";
} else {
echo "Error: " . mysqli_error($connection);
}
mysqli_close($connection);
?>
<?php
session_start();
$connection = mysqli_connect("localhost", "root", "", "platform");
$user_id = $_SESSION['id'];
$query = mysqli_query($connection, "SELECT * FROM btc_transactions WHERE user_id = '$user_id' ORDER BY created_at DESC");
?>
<h3>Your BTC Transactions</h3>
<table border="1">
<tr>
<th>User Wallet</th>
<th>Recipient Wallet</th>
<th>Amount (BTC)</th>
<th>Status</th>
<th>Time</th>
</tr>
<?php while ($tx = mysqli_fetch_assoc($query)) { ?>
<tr>
<td><?= htmlspecialchars($tx['user_wallet']) ?></td>
<td><?= htmlspecialchars($tx['recipient_wallet']) ?></td>
<td><?= $tx['amount_btc'] ?></td>
<td style="color: <?= $tx['status'] == 'success' ? 'green' : ($tx['status'] == 'failed' ? 'red' : 'orange') ?>">
<?= ucfirst($tx['status']) ?>
</td>
<td><?= $tx['created_at'] ?></td>
</tr>
<?php } ?>
</table>