35580-vm/send-money.php
Flatlogic Bot 79236554fd UB
2025-11-09 01:47:20 +00:00

129 lines
6.0 KiB
PHP

<?php
session_start();
require_once 'db/config.php';
if (!isset($_SESSION['user_id'])) {
header("Location: login.php");
exit;
}
$user_id = $_SESSION['user_id'];
$stmt = $pdo->prepare("SELECT * FROM users WHERE id = ?");
$stmt->execute([$user_id]);
$user = $stmt->fetch();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Send Money - UBPay</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="assets/css/custom.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.css">
</head>
<body style="background-color: #F8F9FA;">
<nav class="navbar navbar-expand-lg navbar-light bg-white shadow-sm">
<div class="container">
<a class="navbar-brand" href="dashboard.php" style="color: #00A859; font-weight: bold;">
<i data-feather="dollar-sign" class="me-2"></i>UBPay
</a>
<div class="d-flex">
<a href="dashboard.php" class="btn btn-light">Back to Dashboard</a>
</div>
</div>
</nav>
<div class="container mt-5">
<div class="row justify-content-center">
<div class="col-md-6">
<div class="card shadow-sm" style="border-radius: 0.5rem;">
<div class="card-body p-4">
<h2 class="card-title text-center mb-4" style="color: #00A859; font-weight: 600;">Send Money</h2>
<div class="alert alert-info">
Your current balance is: <strong>$<?php echo htmlspecialchars(number_format($user['balance'], 2)); ?></strong>
</div>
<?php if (isset($_SESSION['message'])): ?>
<div class="alert alert-<?php echo $_SESSION['message_type']; ?> alert-dismissible fade show" role="alert">
<?php echo $_SESSION['message']; ?>
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>
<?php unset($_SESSION['message']); unset($_SESSION['message_type']); ?>
<?php endif; ?>
<form id="send-money-form" action="process-send-money.php" method="POST">
<div class="mb-3">
<label for="recipient" class="form-label">Recipient's Mobile Number</label>
<input type="text" class="form-control" id="recipient" name="recipient" placeholder="Enter mobile number" required>
</div>
<div class="mb-3">
<label for="amount" class="form-label">Amount</label>
<div class="input-group">
<span class="input-group-text" style="color: #00A859;">$</span>
<input type="number" class="form-control" id="amount" name="amount" placeholder="0.00" step="0.01" min="0.01" max="<?php echo $user['balance']; ?>" required>
</div>
</div>
<div class="mb-3">
<label for="notes" class="form-label">Notes (Optional)</label>
<textarea class="form-control" id="notes" name="notes" rows="3" placeholder="Add a note..."></textarea>
</div>
<div class="d-grid">
<button type="button" class="btn btn-primary btn-lg" style="background-color: #00A859; border-color: #00A859;" data-bs-toggle="modal" data-bs-target="#confirmationModal">Send Money</button>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
<!-- Confirmation Modal -->
<div class="modal fade" id="confirmationModal" tabindex="-1" aria-labelledby="confirmationModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="confirmationModalLabel">Confirm Transaction</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<p>Please confirm the details of your transaction:</p>
<ul class="list-group">
<li class="list-group-item"><strong>Recipient:</strong> <span id="confirm-recipient"></span></li>
<li class="list-group-item"><strong>Amount:</strong> $<span id="confirm-amount"></span></li>
<li class="list-group-item"><strong>Notes:</strong> <span id="confirm-notes"></span></li>
</ul>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-primary" id="confirm-send-button" style="background-color: #00A859; border-color: #00A859;">Confirm & Send</button>
</div>
</div>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
<script>
feather.replace();
const confirmationModal = document.getElementById('confirmationModal');
confirmationModal.addEventListener('show.bs.modal', function (event) {
const recipient = document.getElementById('recipient').value;
const amount = document.getElementById('amount').value;
const notes = document.getElementById('notes').value;
document.getElementById('confirm-recipient').textContent = recipient;
document.getElementById('confirm-amount').textContent = parseFloat(amount).toFixed(2);
document.getElementById('confirm-notes').textContent = notes || 'N/A';
});
document.getElementById('confirm-send-button').addEventListener('click', function () {
document.getElementById('send-money-form').submit();
});
</script>
</body>
</html>