File manager - Edit - /var/www/order.cmtc.ac.th/user/checkout_3.php
Back
<?php session_start(); include('../config/db.php'); // ✅ ตรวจสอบว่ามีสินค้าในตะกร้า if(!isset($_SESSION['cart']) || count($_SESSION['cart']) == 0){ header("Location: index.php"); exit; } // ✅ รับข้อมูลจากฟอร์ม $fullname = $_POST['fullname'] ?? ''; $phone = $_POST['phone'] ?? ''; $address = $_POST['address'] ?? ''; $zipcode = $_POST['zipcode'] ?? ''; $receive_method = $_POST['receive_method'] ?? ''; // ✅ ดึงข้อมูลสินค้าจาก session cart $ids = implode(",", array_keys($_SESSION['cart'])); $res = $conn->query("SELECT * FROM products WHERE id IN ($ids)"); $items = []; $total = 0; while($r = $res->fetch_assoc()){ $pid = $r['id']; $qty = $_SESSION['cart'][$pid]; $sum = $r['price'] * $qty; $total += $sum; $items[] = [ 'id' => $pid, 'name' => $r['name'], 'qty' => $qty, 'price' => $r['price'], 'sum' => $sum ]; } // ✅ ดึงข้อมูลบัญชีรับเงิน / พร้อมเพย์จากฐานข้อมูล $acc = $conn->query("SELECT * FROM payment_account LIMIT 1")->fetch_assoc(); $account_type = $acc['account_type'] ?? 'promptpay'; $account_no = $acc['account_no'] ?? '0000000000'; $account_name = $acc['account_name'] ?? 'ไม่ระบุชื่อบัญชี'; $bank_name = $acc['bank_name'] ?? ''; // ✅ สร้างลิงก์ QR PromptPay พร้อมยอดเงิน $amount = number_format($total, 2, '.', ''); $qrText = "https://promptpay.io/" . $account_no . "/" . $amount; ?> <?php include('template_user_header.php'); ?> <!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"> <style> body,*{font-family:'Kanit',sans-serif!important;} .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; } .summary-box { background:#fff; border-radius:10px; padding:20px; box-shadow:0 2px 6px rgba(0,0,0,0.1); } </style> </head> <body class="bg-light"> <div class="container py-5"> <div class="summary-box"> <h4 class="mb-3">📋 สรุปรายการสั่งจอง</h4> <!-- ✅ แสดงข้อมูลผู้จอง --> <div class="mb-4"> <h6 class="text-secondary mb-2">👤 ข้อมูลผู้จอง / ผู้รับสินค้า</h6> <p><b>ชื่อ-นามสกุล:</b> <?=htmlspecialchars($fullname)?></p> <p><b>เบอร์โทรศัพท์:</b> <?=htmlspecialchars($phone)?></p> <p><b>วิธีรับสินค้า:</b> <?=htmlspecialchars($receive_method)?></p> <?php if($receive_method == 'จัดส่งทางไปรษณีย์'): ?> <p><b>ที่อยู่จัดส่ง:</b> <?=nl2br(htmlspecialchars($address))?></p> <p><b>รหัสไปรษณีย์:</b> <?=htmlspecialchars($zipcode)?></p> <?php endif; ?> </div> <!-- ✅ แสดงตารางสินค้า --> <table class="table table-bordered mt-3 bg-white"> <thead class="table-secondary"> <tr class="text-center"> <th>ชื่อเหรียญ</th> <th>จำนวน</th> <th>ราคา/หน่วย</th> <th>รวม</th> </tr> </thead> <tbody> <?php foreach($items as $it): ?> <tr> <td><?=$it['name']?></td> <td class="text-center"><?=$it['qty']?></td> <td class="text-end"><?=number_format($it['price'],2)?></td> <td class="text-end"><?=number_format($it['sum'],2)?></td> </tr> <?php endforeach; ?> <tr class="table-light"> <th colspan="3" class="text-end">ยอดรวมทั้งหมด</th> <th class="text-end text-success"><?=number_format($total,2)?></th> </tr> </tbody> </table> <!-- ✅ 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 d-block mt-2">* โปรดตรวจสอบชื่อบัญชีและยอดเงินก่อนโอน</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-4"> <label>📎 แนบสลิปชำระเงิน (จำเป็น)</label> <input type="file" name="slip" class="form-control" accept="image/*" required> </div> <button class="btn btn-success w-100 py-2">💾 ส่งหลักฐานการชำระเงิน</button> </form> </div> </div> </body> </html>
| ver. 1.4 |
Github
|
.
| PHP 7.4.33 | Generation time: 0.42 |
proxy
|
phpinfo
|
Settings