File manager - Edit - /var/www/order.cmtc.ac.th/user/checkout_2.php
Back
<?php include('../config/db.php'); session_start(); $selected = $_POST['product_id'] ?? []; if(empty($selected)) { header("Location: index.php"); exit; } $fullname = $_POST['fullname'] ?? ''; $phone = $_POST['phone'] ?? ''; $address = $_POST['address'] ?? ''; $zipcode = $_POST['zipcode'] ?? ''; $receive_method = $_POST['receive_method'] ?? ''; $total = 0; $items = []; foreach($selected as $pid){ $q = intval($_POST['qty'][$pid] ?? 1); $r = $conn->query("SELECT * FROM products WHERE id=$pid")->fetch_assoc(); $sum = $r['price']*$q; $total += $sum; $items[] = ['name'=>$r['name'],'qty'=>$q,'price'=>$r['price'],'sum'=>$sum]; } // ✅ ดึงข้อมูลบัญชี / พร้อมเพย์จากฐานข้อมูล $acc = $conn->query("SELECT * FROM payment_account LIMIT 1")->fetch_assoc(); $account_type = $acc['account_type']; $account_no = $acc['account_no']; $account_name = $acc['account_name']; $bank_name = $acc['bank_name']; // ✅ สร้างลิงก์ QR พร้อมเพย์ พร้อมจำนวนเงินแบบ fix // ใช้ API ฟรีของ SCB QR Generator $amount = number_format($total, 2, '.', ''); $qrText = "https://promptpay.io/" . $account_no . "/" . $amount; ?> <!DOCTYPE html> <html lang="th"> <head> <meta charset="UTF-8"> <title>สรุปการสั่งจอง</title> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet"> <link href="../assets/css/style.css" rel="stylesheet"> <style> .qr-box { text-align:center; border:1px dashed #ccc; border-radius:10px; padding:20px; background:#fafafa; } .qr-box img { width:200px; margin:10px auto; } .account-info { text-align:center; font-size:1rem; color:#333; } </style> </head> <body class="bg-light"> <div class="container py-5"> <div class="card shadow p-4"> <h4>สรุปรายการจอง</h4> <table class="table table-bordered mt-3"> <thead><tr><th>ชื่อพระ</th><th>จำนวน</th><th>ราคา/หน่วย</th><th>รวม</th></tr></thead> <tbody> <?php foreach($items as $it): ?> <tr> <td><?=htmlspecialchars($it['name'])?></td> <td><?=$it['qty']?></td> <td><?=number_format($it['price'],2)?></td> <td><?=number_format($it['sum'],2)?></td> </tr> <?php endforeach; ?> <tr><th colspan="3" class="text-end">ยอดรวม</th><th><?=number_format($total,2)?></th></tr> </tbody> </table> <h5 class="mt-3 text-center text-success"> 💰 ยอดที่ต้องชำระ: <b><?=number_format($total,2)?> บาท</b> </h5> <!-- ✅ QR CODE สำหรับชำระเงิน --> <div class="qr-box mt-4"> <h6>สแกน QR Code เพื่อชำระเงิน</h6> <img src="<?=$qrText?>" alt="QR PromptPay"> <div class="account-info"> <p><b>ชื่อบัญชี:</b> <?=$account_name?></p> <?php if($account_type == 'bank'): ?> <p><b>ธนาคาร:</b> <?=$bank_name?><br><b>เลขบัญชี:</b> <?=$account_no?></p> <?php else: ?> <p><b>หมายเลขพร้อมเพย์:</b> <?=$account_no?></p> <?php endif; ?> <small class="text-muted">* โปรดตรวจสอบชื่อบัญชีและยอดเงินก่อนโอน</small> </div> </div> <form method="post" action="upload_slip.php" enctype="multipart/form-data" class="mt-4"> <input type="hidden" name="fullname" value="<?=htmlspecialchars($fullname)?>"> <input type="hidden" name="phone" value="<?=htmlspecialchars($phone)?>"> <input type="hidden" name="address" value="<?=htmlspecialchars($address)?>"> <input type="hidden" name="zipcode" value="<?=htmlspecialchars($zipcode)?>"> <input type="hidden" name="receive_method" value="<?=htmlspecialchars($receive_method)?>"> <input type="hidden" name="total" value="<?=htmlspecialchars($total)?>"> <?php foreach($items as $i): ?> <input type="hidden" name="product_name[]" value="<?=htmlspecialchars($i['name'])?>"> <input type="hidden" name="qty[]" value="<?=$i['qty']?>"> <input type="hidden" name="price[]" value="<?=$i['price']?>"> <?php endforeach; ?> <div class="mb-3 mt-3"> <label>แนบสลิปชำระเงิน</label> <input type="file" name="slip" class="form-control" required> </div> <button class="btn btn-success w-100">ส่งหลักฐานการชำระเงิน</button> </form> </div> </div> </body> </html>
| ver. 1.4 |
Github
|
.
| PHP 7.4.33 | Generation time: 0.41 |
proxy
|
phpinfo
|
Settings