0 Comments

充值引导程序

发布于:2012-11-24  |   作者:广州网站建设  |   已聚集:人围观
充值引导程序

充值引导程序的需要实现的功能有两个:

(1)获得当前用户的账户余额;

(2)加载充值引导页面。

为了便于用户直观地了解提交信息的情况,在文件最后插入了一段HTML页面监测代码。创建文件名为pay.php的PHP脚本程序,具体代码如下:

广州网站建设
  1. <?php 
  2. /*******************************************  
  3. '文件名:pay.php  
  4. '主要功能:支付引导程序  
  5. '说明:  
  6.  *******************************************/  
  7. require_once (dirname ( __FILE__ ) . "/inc/inc.read.dbconfig.php");  
  8.                                             //数据库配置文件  
  9. require_once (dirname ( __FILE__ ) . "/include/include.functions.php");  
  10.                                             //公共函数库文件  
  11. include_once (dirname ( __FILE__ ) . "/include.smarty.php");  
  12.                                             //加载模板引擎配置文件  
  13. $mysql = mysql_connect ( $mysqlconf ["host"], $mysqlconf ["user"], $mysqlconf ["pass"] ) or die ( 'Not connected : ' . mysql_error () );  
  14. mysql_select_db ( $mysqlconf ["db"], $mysql ) or die ( 'Can\'t use foo : ' . mysql_error () );  
  15. $uids = $_GET ['uid'];  
  16. $SurplusSurplus = Surplus ( $uids, $mysql );       //当前用户账户剩余货币数量  
  17. //确认规则!  
  18. $orderid = time ();                         //生成统一的订单编号  
  19. $smarty->assign ( "uid", $uids );  
  20. $smarty->assign ( "orderid", $orderid );    //生成订单变量的Smarty标签  
  21. $smarty->assign ( "Surplus", $Surplus );    //生成剩余货币变量的Smarty标签  
  22. $smarty->display ( "./pay.html" );          //显示输出模板  
  23. mysql_close ( $mysql );                     //关闭数据库连接  
  24. ?> 

【代码解读】

以上代码的作用是支付引导。这里需要注意的是,uid需要通过Get的方式获得,读者可以根据具体的需要,创建自动获得当前uid的函数。

在浏览器中执行下面的链接:

广州网站设计
  1. http://localhost/payment/pay.php?uid=10 

在浏览器中预览如图12.2所示。

图12.2  充值引导预览
标签:
飞机