NenTang.vn
Thiết kế Lập trình Web BackendLập trình căn bản PHP
Thực hiện Trang Chi tiết Sản phẩm Product Detail
Chương 11 · Bài 5
Dự án thực tế mẫu (PHP thuần) - Trang web bán hàng trực tuyến - Thiết kế Frontend
Thời lượng: 45 phútĐọc khoảng: 11 phút
Danh mục hình và bảng
Từ viết tắt
Nội dung bài học không khai báo từ viết tắt bằng thẻ abbr.
Nội dung bài học
Workflow xử lý
typescript
1sequenceDiagram2 autonumber3 participant C as Client4 participant S as Server5 participant A as API6 participant DB as Database7 8 C ->> +S: Gởi yêu cầu (Request GET) kèm tham số (parameter) sp_ma={...}9 note right of C: https://nentang.vn/frontend/sanpham/detail.php?sp_ma=510 11 S ->> S: phân tách dữ liệu từ người dùng gởi đến trong biến $_GET12 note right of S: lấy dữ liệu $_GET['sp_ma']13 S ->> +DB: thực thi câu lệnh (SQL QUERY) lấy thông tin Sản phẩm theo sp_ma14 note over S,DB: SELECT * FROM sanpham WHERE sp_ma = $sp_ma ...15 DB -->> -S: Database trả về Khối dữ liệu16 17 S ->> S: phân tách khối dữ liệu18 S ->> S: render giao diện Sản phẩm19 S --x -C: trả về Phản hồi (response) giao diện FORM Chi tiết Sản phẩm20 21 C ->> +A: khi người dùng nhập Số lượng và Bấm Thêm vào Giỏ hàng, gọi AJAX đến API giohang-themsanpham.php22 A ->> S: lưu thông tin Sản phẩm vào Giỏ hàng trong SESSION23 A -->> -C: trả về thông tin theo định dạng JSON Format24 C -x C: cập nhật lại phần giao diện tương ứngGiao diện trang Chi tiết Sản phẩm
Xem thêm bài khái niệm API và Web API là gì?
Step 1: tạo API thêm Sản phẩm vào Giỏ hàng trong Session
- Tạo file
frontend/api/giohang-themsanpham.php
php
1<?php2// hàm `session_id()` sẽ trả về giá trị SESSION_ID (tên file session do Web Server tự động tạo)3// - Nếu trả về Rỗng hoặc NULL => chưa có file Session tồn tại4if (session_id() === '') {5 // Yêu cầu Web Server tạo file Session để lưu trữ giá trị tương ứng với CLIENT (Web Browser đang gởi Request)6 session_start();7}8 9// Truy vấn database để lấy danh sách10// 1. Include file cấu hình kết nối đến database, khởi tạo kết nối $conn11include_once(__DIR__ . '/../../dbconnect.php');12 13// 2. Lấy thông tin người dùng gởi đến14$sp_ma = $_POST['sp_ma'];15$sp_ten = $_POST['sp_ten'];16$soluong = $_POST['soluong'];17$gia = $_POST['sp_gia'];18$hinhdaidien = $_POST['hinhdaidien'];19 20// 3. Lưu trữ giỏ hàng trong session21// Nếu khách hàng đặt hàng cùng sản phẩm đã có trong giỏ hàng => cập nhật lại Số lượng, Thành tiền22if (isset($_SESSION['giohangdata'])) {23 $data = $_SESSION['giohangdata'];24 $data[$sp_ma] = array(25 'sp_ma' => $sp_ma,26 'sp_ten' => $sp_ten,27 'soluong' => $soluong,28 'gia' => $gia,29 'thanhtien' => ($soluong * $gia),30 'hinhdaidien' => $hinhdaidien31 );32 33 // lưu dữ liệu giỏ hàng vào session34 $_SESSION['giohangdata'] = $data;35} else { // Nếu khách hàng đặt hàng sản phẩm chưa có trong giỏ hàng => thêm vào36 $data[$sp_ma] = array(37 'sp_ma' => $sp_ma,38 'sp_ten' => $sp_ten,39 'soluong' => $soluong,40 'gia' => $gia,41 'thanhtien' => ($soluong * $gia),42 'hinhdaidien' => $hinhdaidien43 );44 45 // lưu dữ liệu giỏ hàng vào session46 $_SESSION['giohangdata'] = $data;47}48 49// 4. Chuyển đổi dữ liệu về định dạng JSON50// Dữ liệu JSON, từ array PHP -> JSON 51echo json_encode($_SESSION['giohangdata']);Step 2: tạo API xóa Sản phẩm trong Giỏ hàng Session
- Tạo file
frontend/api/giohang-xoasanpham.php
php
1<?php2// hàm `session_id()` sẽ trả về giá trị SESSION_ID (tên file session do Web Server tự động tạo)3// - Nếu trả về Rỗng hoặc NULL => chưa có file Session tồn tại4if (session_id() === '') {5 // Yêu cầu Web Server tạo file Session để lưu trữ giá trị tương ứng với CLIENT (Web Browser đang gởi Request)6 session_start();7}8 9// Truy vấn database để lấy danh sách10// 1. Include file cấu hình kết nối đến database, khởi tạo kết nối $conn11include_once(__DIR__ . '/../../dbconnect.php');12 13// Lấy thông tin người dùng gởi đến14$sp_ma = $_POST['sp_ma'];15 16// 2. Lưu trữ giỏ hàng trong session17// Nếu khách hàng đặt hàng cùng sản phẩm đã có trong giỏ hàng => cập nhật lại Số lượng, Thành tiền18if (isset($_SESSION['giohangdata'])) {19 $data = $_SESSION['giohangdata'];20 21 if(isset($data[$sp_ma])) {22 unset($data[$sp_ma]);23 }24 25 // lưu dữ liệu giỏ hàng vào session26 $_SESSION['giohangdata'] = $data;27}28 29// 3. Chuyển đổi dữ liệu về định dạng JSON30// Dữ liệu JSON, từ array PHP -> JSON 31echo json_encode($_SESSION['giohangdata']);Step 3: tạo API cập nhật Sản phẩm trong Giỏ hàng Session
- Tạo file
frontend/api/giohang-capnhatsanpham.php
php
1<?php2// hàm `session_id()` sẽ trả về giá trị SESSION_ID (tên file session do Web Server tự động tạo)3// - Nếu trả về Rỗng hoặc NULL => chưa có file Session tồn tại4if (session_id() === '') {5 // Yêu cầu Web Server tạo file Session để lưu trữ giá trị tương ứng với CLIENT (Web Browser đang gởi Request)6 session_start();7}8 9// Truy vấn database để lấy danh sách10// 1. Include file cấu hình kết nối đến database, khởi tạo kết nối $conn11include_once(__DIR__ . '/../../dbconnect.php');12 13// 2. Lấy thông tin người dùng gởi đến14$sp_ma = $_POST['sp_ma'];15$soluong = $_POST['soluong'];16 17// 3. Lưu trữ giỏ hàng trong session18// Nếu khách hàng đặt hàng cùng sản phẩm đã có trong giỏ hàng => cập nhật lại Số lượng, Thành tiền19if (isset($_SESSION['giohangdata'])) {20 $data = $_SESSION['giohangdata'];21 $sanphamcu = $data[$sp_ma];22 23 $data[$sp_ma] = array(24 'sp_ma' => $sanphamcu['sp_ma'],25 'sp_ten' => $sanphamcu['sp_ten'],26 'soluong' => $soluong,27 'gia' => $sanphamcu['gia'],28 'thanhtien' => ($soluong * $sanphamcu['gia']),29 'hinhdaidien' => $sanphamcu['hinhdaidien']30 );31 32 // lưu dữ liệu giỏ hàng vào session33 $_SESSION['giohangdata'] = $data;34}35 36// 4. Chuyển đổi dữ liệu về định dạng JSON37// Dữ liệu JSON, từ array PHP -> JSON 38echo json_encode($_SESSION['giohangdata']);Step 4: Tạo giao diện Trang chi tiết sản phẩm
- Tạo file
/frontend/sanpham/detail.php - Nội dung file:
php
1<?php2// hàm `session_id()` sẽ trả về giá trị SESSION_ID (tên file session do Web Server tự động tạo)3// - Nếu trả về Rỗng hoặc NULL => chưa có file Session tồn tại4if (session_id() === '') {5 // Yêu cầu Web Server tạo file Session để lưu trữ giá trị tương ứng với CLIENT (Web Browser đang gởi Request)6 session_start();7}8?>9 10<!DOCTYPE html>11<html>12 13<head>14 <meta charset="UTF-8">15 <meta name="viewport" content="width=device-width, initial-scale=1.0">16 <title>NenTang.vn</title>17 18 <!-- Nhúng file Quản lý các Liên kết CSS dùng chung cho toàn bộ trang web -->19 <?php include_once(__DIR__ . '/../layouts/styles.php'); ?>20 21 <link href="/php/myhand/assets/frontend/css/style.css" type="text/css" rel="stylesheet" />22 23 <style>24 body {25 font-family: 'open sans';26 overflow-x: hidden;27 }28 29 img {30 max-width: 100%;31 }32 33 .preview {34 display: -webkit-box;35 display: -webkit-flex;36 display: -ms-flexbox;37 display: flex;38 -webkit-box-orient: vertical;39 -webkit-box-direction: normal;40 -webkit-flex-direction: column;41 -ms-flex-direction: column;42 flex-direction: column;43 }44 45 @media screen and (max-width: 996px) {46 .preview {47 margin-bottom: 20px;48 }49 }50 51 .preview-pic {52 -webkit-box-flex: 1;53 -webkit-flex-grow: 1;54 -ms-flex-positive: 1;55 flex-grow: 1;56 max-height: 300px;57 }58 59 .preview-thumbnail.nav-tabs {60 border: none;61 margin-top: 15px;62 }63 64 .preview-thumbnail.nav-tabs li {65 width: 18%;66 margin-right: 2.5%;67 }68 69 .preview-thumbnail.nav-tabs li img {70 max-width: 100%;71 display: block;72 }73 74 .preview-thumbnail.nav-tabs li a {75 padding: 0;76 margin: 0;77 }78 79 .preview-thumbnail.nav-tabs li:last-of-type {80 margin-right: 0;81 }82 83 .tab-content {84 overflow: hidden;85 }86 87 .tab-content img {88 width: 100%;89 -webkit-animation-name: opacity;90 animation-name: opacity;91 -webkit-animation-duration: .3s;92 animation-duration: .3s;93 }94 95 .card {96 margin-top: 50px;97 background: #eee;98 padding: 3em;99 line-height: 1.5em;100 }101 102 @media screen and (min-width: 997px) {103 .wrapper {104 display: -webkit-box;105 display: -webkit-flex;106 display: -ms-flexbox;107 display: flex;108 }109 }110 111 .details {112 display: -webkit-box;113 display: -webkit-flex;114 display: -ms-flexbox;115 display: flex;116 -webkit-box-orient: vertical;117 -webkit-box-direction: normal;118 -webkit-flex-direction: column;119 -ms-flex-direction: column;120 flex-direction: column;121 }122 123 .colors {124 -webkit-box-flex: 1;125 -webkit-flex-grow: 1;126 -ms-flex-positive: 1;127 flex-grow: 1;128 }129 130 .product-title,131 .price,132 .sizes,133 .colors {134 text-transform: UPPERCASE;135 font-weight: bold;136 }137 138 .checked,139 .price span {140 color: #ff9f1a;141 }142 143 .product-title,144 .rating,145 .product-description,146 .price,147 .vote,148 .sizes {149 margin-bottom: 15px;150 }151 152 .product-title {153 margin-top: 0;154 }155 156 .size {157 margin-right: 10px;158 }159 160 .size:first-of-type {161 margin-left: 40px;162 }163 164 .color {165 display: inline-block;166 vertical-align: middle;167 margin-right: 10px;168 height: 2em;169 width: 2em;170 border-radius: 2px;171 }172 173 .color:first-of-type {174 margin-left: 20px;175 }176 177 .add-to-cart,178 .like {179 background: #ff9f1a;180 padding: 1.2em 1.5em;181 border: none;182 text-transform: UPPERCASE;183 font-weight: bold;184 color: #fff;185 -webkit-transition: background .3s ease;186 transition: background .3s ease;187 }188 189 .add-to-cart:hover,190 .like:hover {191 background: #b36800;192 color: #fff;193 }194 195 .not-available {196 text-align: center;197 line-height: 2em;198 }199 200 .not-available:before {201 font-family: fontawesome;202 content: "\f00d";203 color: #fff;204 }205 206 .orange {207 background: #ff9f1a;208 }209 210 .green {211 background: #85ad00;212 }213 214 .blue {215 background: #0076ad;216 }217 218 .tooltip-inner {219 padding: 1.3em;220 }221 222 @-webkit-keyframes opacity {223 0% {224 opacity: 0;225 -webkit-transform: scale(3);226 transform: scale(3);227 }228 229 100% {230 opacity: 1;231 -webkit-transform: scale(1);232 transform: scale(1);233 }234 }235 236 @keyframes opacity {237 0% {238 opacity: 0;239 -webkit-transform: scale(3);240 transform: scale(3);241 }242 243 100% {244 opacity: 1;245 -webkit-transform: scale(1);246 transform: scale(1);247 }248 }249 </style>250</head>251 252<body class="d-flex flex-column h-100">253 <!-- header -->254 <?php include_once(__DIR__ . '/../layouts/partials/header.php'); ?>255 <!-- end header -->256 257 <main role="main" class="mb-2">258 <!-- Block content -->259 <?php260 // Hiển thị tất cả lỗi trong PHP261 // Chỉ nên hiển thị lỗi khi đang trong môi trường Phát triển (Development)262 // Không nên hiển thị lỗi trên môi trường Triển khai (Production)263 ini_set('display_errors', 1);264 ini_set('display_startup_errors', 1);265 error_reporting(E_ALL);266 267 // Truy vấn database268 // 1. Include file cấu hình kết nối đến database, khởi tạo kết nối $conn269 include_once(__DIR__ . '/../../dbconnect.php');270 271 /* --- 272 --- 2.Truy vấn dữ liệu Sản phẩm 273 --- Lấy giá trị khóa chính được truyền theo dạng QueryString Parameter key1=value1&key2=value2...274 --- 275 */276 $sp_ma = $_GET['sp_ma'];277 $sqlSelectSanPham = <<<EOT278 SELECT sp.sp_ma, sp.sp_ten, sp.sp_gia, sp.sp_giacu, sp.sp_mota_ngan, sp.sp_mota_chitiet, sp.sp_soluong, lsp.lsp_ten279 FROM `sanpham` sp280 JOIN `loaisanpham` lsp ON sp.lsp_ma = lsp.lsp_ma281 WHERE sp.sp_ma = $sp_ma282EOT;283 284 // Thực thi câu truy vấn SQL để lấy về dữ liệu ban đầu của record 285 $resultSelectSanPham = mysqli_query($conn, $sqlSelectSanPham);286 287 // Khi thực thi các truy vấn dạng SELECT, dữ liệu lấy về cần phải phân tích để sử dụng288 // Thông thường, chúng ta sẽ sử dụng vòng lặp while để duyệt danh sách các dòng dữ liệu được SELECT289 // Ta sẽ tạo 1 mảng array để chứa các dữ liệu được trả về290 $sanphamRow;291 while ($row = mysqli_fetch_array($resultSelectSanPham, MYSQLI_ASSOC)) {292 $sanphamRow = array(293 'sp_ma' => $row['sp_ma'],294 'sp_ten' => $row['sp_ten'],295 'sp_gia' => $row['sp_gia'],296 'sp_gia_formated' => number_format($row['sp_gia'], 2, ".", ",") . ' vnđ',297 'sp_giacu_formated' => number_format($row['sp_giacu'], 2, ".", ",") . ' vnđ',298 'sp_mota_ngan' => $row['sp_mota_ngan'],299 'sp_mota_chitiet' => $row['sp_mota_chitiet'],300 'sp_soluong' => $row['sp_soluong'],301 'lsp_ten' => $row['lsp_ten']302 );303 }304 /* --- End Truy vấn dữ liệu Sản phẩm --- */305 306 /* --- 307 --- 3.Truy vấn dữ liệu Hình ảnh Sản phẩm 308 --- 309 */310 $sqlSelect = <<<EOT311 SELECT hsp.hsp_ma, hsp.hsp_tentaptin312 FROM `hinhsanpham` hsp313 WHERE hsp.sp_ma = $sp_ma314EOT;315 316 // Thực thi câu truy vấn SQL để lấy về dữ liệu ban đầu của record 317 $result = mysqli_query($conn, $sqlSelect);318 319 // Khi thực thi các truy vấn dạng SELECT, dữ liệu lấy về cần phải phân tích để sử dụng320 // Thông thường, chúng ta sẽ sử dụng vòng lặp while để duyệt danh sách các dòng dữ liệu được SELECT321 // Ta sẽ tạo 1 mảng array để chứa các dữ liệu được trả về322 $danhsachhinhanh = [];323 while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) {324 $danhsachhinhanh[] = array(325 'hsp_ma' => $row['hsp_ma'],326 'hsp_tentaptin' => $row['hsp_tentaptin']327 );328 }329 /* --- End Truy vấn dữ liệu Hình ảnh sản phẩm --- */330 331 // Hiệu chỉnh dữ liệu theo cấu trúc để tiện xử lý332 $sanphamRow['danhsachhinhanh'] = $danhsachhinhanh;333 ?>334 335 <div class="container mt-4">336 <!-- Vùng ALERT hiển thị thông báo -->337 <div id="alert-container" class="alert alert-warning alert-dismissible fade d-none" role="alert">338 <div id="thongbao"> </div>339 <button type="button" class="close" data-dismiss="alert" aria-label="Close">340 <span aria-hidden="true">×</span>341 </button>342 </div>343 344 <div class="card">345 <div class="container-fliud">346 <form name="frmsanphamchitiet" id="frmsanphamchitiet" method="post" action="">347 <?php348 $hinhsanphamdautien = empty($sanphamRow['danhsachhinhanh'][0]) ? '' : $sanphamRow['danhsachhinhanh'][0];349 ?>350 <input type="hidden" name="sp_ma" id="sp_ma" value="<?= $sanphamRow['sp_ma'] ?>" />351 <input type="hidden" name="sp_ten" id="sp_ten" value="<?= $sanphamRow['sp_ten'] ?>" />352 <input type="hidden" name="sp_gia" id="sp_gia" value="<?= $sanphamRow['sp_gia'] ?>" />353 <input type="hidden" name="hinhdaidien" id="hinhdaidien" value="<?= empty($hinhsanphamdautien) ? '' : $hinhsanphamdautien['hsp_tentaptin'] ?>" />354 355 <div class="wrapper row">356 <div class="preview col-md-6">357 <!-- Nếu có hình sản phẩm nào => duyệt vòng lặp để hiển thị các hình ảnh -->358 <?php if (count($sanphamRow['danhsachhinhanh']) > 0) : ?>359 <div class="preview-pic tab-content">360 <?php foreach ($sanphamRow['danhsachhinhanh'] as $hinhsanpham) : ?>361 <div class="tab-pane <?= ($hinhsanpham == $hinhsanphamdautien) ? 'active' : '' ?>" id="pic-<?= $hinhsanpham['hsp_ma'] ?>">362 <img src="/php/myhand/assets/uploads/products/<?= $hinhsanpham['hsp_tentaptin'] ?>" />363 </div>364 <?php endforeach; ?>365 </div>366 <ul class="preview-thumbnail nav nav-tabs">367 <?php foreach ($sanphamRow['danhsachhinhanh'] as $hinhsanpham) : ?>368 <li class="<?= ($hinhsanpham == $hinhsanphamdautien) ? 'active' : '' ?>">369 <a data-target="#pic-<?= $hinhsanpham['hsp_ma'] ?>" data-toggle="tab">370 <img src="/php/myhand/assets/uploads/products/<?= $hinhsanpham['hsp_tentaptin'] ?>" />371 </a>372 </li>373 <?php endforeach; ?>374 </ul>375 <!-- Không có hình sản phẩm nào => lấy ảnh mặc định -->376 <?php else : ?>377 <div class="preview-pic tab-content">378 <div class="tab-pane active" id="pic-1">379 <img src="/php/myhand/assets/shared/img/default-image_600.png" />380 </div>381 </div>382 <ul class="preview-thumbnail nav nav-tabs">383 <li class="active">384 <a data-target="#pic-1" data-toggle="tab">385 <img src="/php/myhand/assets/shared/img/default-image_600.png" />386 </a>387 </li>388 </ul>389 <?php endif; ?>390 </div>391 <div class="details col-md-6">392 <h3 class="product-title"><?= $sanphamRow['sp_ten'] ?></h3>393 <div class="rating">394 <div class="stars">395 <span class="fa fa-star checked"></span>396 <span class="fa fa-star checked"></span>397 <span class="fa fa-star checked"></span>398 <span class="fa fa-star"></span>399 <span class="fa fa-star"></span>400 </div>401 <span class="review-no">999 đánh giá</span>402 </div>403 <p class="product-description"><?= $sanphamRow['sp_mota_ngan'] ?></p>404 <small class="text-muted">Giá cũ: <s><span><?= $sanphamRow['sp_giacu_formated'] ?></span></s></small>405 <h4 class="price">Giá hiện tại: <span><?= $sanphamRow['sp_gia_formated'] ?></span></h4>406 <p><?= $sanphamRow['sp_mota_ngan'] ?></p>407 <p class="vote"><strong>100%</strong> hàng <strong>Chất lượng</strong>, đảm bảo <strong>Uy408 tín</strong>!</p>409 <h5 class="sizes">sizes:410 <span class="size" data-toggle="tooltip" title="cỡ Nhỏ">s</span>411 <span class="size" data-toggle="tooltip" title="cỡ Trung bình">m</span>412 <span class="size" data-toggle="tooltip" title="cỡ Lớn">l</span>413 <span class="size" data-toggle="tooltip" title="cỡ Đại">xl</span>414 </h5>415 <h5 class="colors">colors:416 <span class="color orange not-available" data-toggle="tooltip" title="Hết hàng"></span>417 <span class="color green"></span>418 <span class="color blue"></span>419 </h5>420 <div class="form-group">421 <label for="soluong">Số lượng đặt mua:</label>422 <input type="number" class="form-control" id="soluong" name="soluong">423 </div>424 <div class="action">425 <a class="add-to-cart btn btn-default" id="btnThemVaoGioHang">Thêm vào giỏ hàng</a>426 <a class="like btn btn-default" href="#"><span class="fa fa-heart"></span></a>427 </div>428 </div>429 </form>430 </div>431 </div>432 </div>433 434 <div class="card">435 <div class="container-fluid">436 <h3>Thông tin chi tiết về Sản phẩm</h3>437 <div class="row">438 <div class="col">439 <?= $sanphamRow['sp_mota_chitiet'] ?>440 </div>441 </div>442 </div>443 </div>444 445 <!-- End block content -->446 </main>447 448 <!-- footer -->449 <?php include_once(__DIR__ . '/../layouts/partials/footer.php'); ?>450 <!-- end footer -->451 452 <!-- Nhúng file quản lý phần SCRIPT JAVASCRIPT -->453 <?php include_once(__DIR__ . '/../layouts/scripts.php'); ?>454 455 <!-- Các file Javascript sử dụng riêng cho trang này, liên kết tại đây -->456 <script>457 function addSanPhamVaoGioHang() {458 // Chuẩn bị dữ liệu gởi459 var dulieugoi = {460 sp_ma: $('#sp_ma').val(),461 sp_ten: $('#sp_ten').val(),462 sp_gia: $('#sp_gia').val(),463 hinhdaidien: $('#hinhdaidien').val(),464 soluong: $('#soluong').val(),465 };466 // console.log((dulieugoi));467 468 // Gọi AJAX đến API ở URL `/php/myhand/frontend/api/giohang-themsanpham.php`469 $.ajax({470 url: '/php/myhand/frontend/api/giohang-themsanpham.php',471 method: "POST",472 dataType: 'json',473 data: dulieugoi,474 success: function(data) {475 console.log(data);476 var htmlString =477 `Sản phẩm đã được thêm vào Giỏ hàng. <a href="/php/myhand/frontend/thanhtoan/giohang.php">Xem Giỏ hàng</a>.`;478 $('#thongbao').html(htmlString);479 // Hiện thông báo480 $('.alert').removeClass('d-none').addClass('show');481 },482 error: function(jqXHR, textStatus, errorThrown) {483 console.log(textStatus, errorThrown);484 var htmlString = `<h1>Không thể xử lý</h1>`;485 $('#thongbao').html(htmlString);486 // Hiện thông báo487 $('.alert').removeClass('d-none').addClass('show');488 }489 });490 };491 492 // Đăng ký sự kiện cho nút Thêm vào giỏ hàng493 $('#btnThemVaoGioHang').click(function(event) {494 event.preventDefault();495 addSanPhamVaoGioHang();496 });497 </script>498</body>499 500</html>Hướng dẫn
Đoạn code bắt buộc phải có để có thể sử dụng SESSION trong PHP
NenTang.vn
Hướng dẫn
Lấy dữ liệu từ người dùng gởi đến qua REQUEST GET
NenTang.vn

