php实现购物车功能(上)(6)

function display_shipping($shipping) //输出包含运费的总价 { ?> <table cellspacing="0"> <tr> <td>Shipping</td> <td> <?php echo number_format($shipping, 2); ?></td> </tr> <tr> <th bgcolor="#cccccc">TOTAL INCLUDING SHIPPING</th> <th bgcolor="#cccccc">$ <?php echo number_format($shipping+$_SESSION['total_price'], 2); ?></th> </tr> </table> <br /> <?php }

5.10 output_fns.php文件中的函数display_card_form()

function display_card_form($name) //输出信用卡信息 { ?> <table cellspacing="0"> <form action="process.php" method="post"> <tr> <th colspan="2" bgcolor="#cccccc">Credit Card Details</th> </tr> <tr> <td>Type</td> <td> <select> <option value="VISA">VISA</option> <option value="MasterCard">MasterCard</option> <option value="American Express">American Express</option> </select> </td> </tr> <tr> <td>Number</td> <td><input type="text" value="" maxlength="16" size="40"/></td> </tr> <tr> <td>AMEX code (if required)</td> <td><input type="text" value="" maxlength="4" size="4"/></td> </tr> <tr> <td>Expiry Date</td> <td>Month <select> <option value="01">01</option> <option value="02">02</option> <option value="03">03</option> <option value="04">04</option> <option value="05">05</option> <option value="06">06</option> <option value="07">07</option> <option value="08">08</option> <option value="09">09</option> <option value="10">10</option> <option value="11">11</option> <option value="12">12</option> </select> Year <select> <?php for($y = date("Y"); $y < date("Y") + 10; $y++) echo "<option value =https://www.jb51.net/article/\"". $y ."https://www.jb51.net/article/\">" . $y ."</option>"; ?> </select> </td> </tr> <tr> <td>Name on Card</td> <td><input type="text" value="<?php echo $name; ?>" maxlength="40" size="40"/></td> </tr> <tr> <td colspan="2"> <p> <strong>Please press Purchase to confirm yout purchase, or Continue Shopping to add or remove items</strong> </p> <?php display_form_button('purchase','Purchase These Items'); ?> </td> </tr> </table> <?php }

5.11 db_fns.php文件中的函数db_connect()

function db_connect() //连接数据库 { $result = new mysqli('localhost','book_sc','password','book_sc'); if(!$result) //连接失败 return false; $result ->autocommit(true); return $result; }

6、实现付款


已填写好信息的信用卡详细信息


购物成功

由以下代码实现:
6.1 process.php

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/233b49197e1240bf53f3b28b4b1c2f2e.html