<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                通過一個小的項目,讓大家理解 session 的作用,以及 PHP 對 session 的基本操作。 功能實現: * 商城里選購商品,添加購物車 * 處理商品訂單 * 商品結算 由于涉及到許多界面的編寫,我這里就只列出各個文件中的主要邏輯代碼,詳細的代碼,請參考上面我提供的代碼文件地址。 所有代碼文件目錄均位于`/usr/share/nginx/html`。 **商品選購頁面 index.php:** ~~~php <?php session_start(); //為了測試的方便,進入此頁面,清空session $_SESSION = null; ?> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>文件上傳</title> <link href="bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"> </head> <body style="height: 800px"> <div class="container"> <!-- 略 --> </div> <script src="bootcss.com/jquery/3.0.0/jquery.min.js"></script> <script> $(document).ready(function() { $('.buyBtn').each(function(index, el) { $(this).on('click', function(event) { let that = $(this); let id = $(this).attr('id'); //商品id $.post('shopProcess.php', {id: id}, function(data, textStatus, xhr) { //Ajax向后臺傳輸數據 if (textStatus == 'success') { that.siblings().css('display','inline'); that.removeClass('btn-primary'); that.addClass('btn-success'); that.text('已加入'); } }); }); }); }); </script> </body> </html> ~~~ ![此處輸入圖片的描述](https://doc.shiyanlou.com/document-uid108299labid1396timestamp1484389175895.png) **商品訂單處理 shopProcess.php:** ~~~php <?php session_start(); $shops = [ //商品信息 ['name'=>'Kali 滲透測試-后門技術實戰','price'=>100], ['name'=>'Kali 滲透測試-Web應用攻擊實戰','price'=>100], ['name'=>'Kali 滲透測試-服務器攻擊實戰','price'=>100], ['name'=>'由淺入深學網絡','price'=>100], ['name'=>'動手實戰學Docker','price'=>100], ['name'=>'Python 經典項目實戰','price'=>100] ]; $id = $_POST['id']-1; //商品id-1,因為索引從0開始 $details = $shops[$id]; $_SESSION['shop '.$id] = $details; //將商品信息存入session; var_dump($_SESSION); ~~~ **商品結算頁面 shopCart.php:** ~~~php <?php foreach ($_SESSION as $key => $value) { //將session中的信息讀取出來 ?> <tr> <td><?php echo $value['name']; ?></td> <td>1</td> <td><?php echo $value['price']; ?></td> </tr> <?php } ?> ~~~ ![此處輸入圖片的描述](https://doc.shiyanlou.com/document-uid108299labid1396timestamp1484389582764.png)
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看